Select a folder in Blackberry webworks - blackberry

Seems quite simple to select a file using webworks, what's not so simple is to select a folder, any one managed this?

You would need to zip the folder into a single file and then run webworks on it.
As far as I know you can't run a webworks function on a folder.

I guess your answer is correct - you CANNOT select a folder using websworks, the method I used was to select a file in that folder, get that the location string of the file and remove the file name.
Obviously, if you don't have a file in that folder, it doesn't work.
Sucky, sucky.

It depends on the platform. There is a blackberry.io.dir API that's supported on OS 5/6/7 and PlayBook:
https://developer.blackberry.com/html5/apis/blackberry.io.dir.html
BlackBerry 10 and PlayBook also support the HTML5 FileReader API which can be used to get at directory info:
https://developer.blackberry.com/html5/apis/directoryentry.html

There is another dirty workaround, you can use FilePicker with mode
mode: blackberry.invoke.card.FILEPICKER_MODE_SAVER_MULTIPLE
This will allow you to select even an empty folder. The downside is that the user needs to click the Save button on the top of the card in order to get the folder path.
Sample code:
// filepicker options
var details = {
mode: blackberry.invoke.card.FILEPICKER_MODE_SAVER_MULTIPLE,
};
blackberry.invoke.card.invokeFilePicker(details, function(path) {
alert('' + path);
},

Related

How do I locate/access PDF files generated through my app on iOS?

I'm using https://github.com/christopherdro/react-native-html-to-pdf to generate PDF files.
On Android they end up in my Download folder and all is good, on iOS however they end up in:
/var/mobile/Containers/Data/Application/xxxxxxxxxx/Documents/xxxx.pdf
How do users then locate the files? I assumed they would be visible in the "Files" app but they're not.
I'm basically doing this for iOS:
let options = {
html: '<h1>PDF TEST</h1>',
fileName: 'test',
directory: 'Documents',
};
I've tried without supplying a directory, or "docs" instead of "Documents" which put them in the same place but /temp instead of /Documents.
Am I doing something wrong? How are iOS users supposed to locate/access the PDF files without having to go through a bunch of stuff to access that folder? Is it possible to make them appear in the "Files" by default?
Thanks in advance.
I figured it out.
You have to add "UIFileSharingEnabled" and "LSSupportsOpeningDocumentsInPlace" into your Info.plist with the value "YES".
That shows the documents folder for your app on an iPhone.

access assets from monodroid class library

Is it possible to access files (with build action "AndroidAsset") from a monodroid class library in a monodroid application that references the class library ?
I have created an "Assets" folder in the class lib and added a text file with build action "AndroidAsset", but from the app I could not access it via Assets.Open("file.txt");
I was hoping that the Assets from the class lib and the main application could somehow be "merged"...
No - you a can't access the assets from a class lib - only from the main exe project.
This is similar to the situation with Java Android projects.
One route around this might be to use embedded resources instead - see the answer to this question I asked on xamarin's forums - http://forums.xamarin.com/discussion/186/is-there-a-cross-platform-way-to-include-string-resources-from-class-library-projects - note that I haven't tried this yet
Is it possible to access files (with build action "AndroidAsset") from a monodroid class library in a monodroid application that references the class library ?
Yes. Just access them "as normal" via Context.Assets.Open. There is only one source of assets in the application, so any component can access any and all assets, if they have access to an AssetManager instance.
However, that just takes what you're asking at face-value. Can a Library project use the Context.Assets property? Certainly, if you provide it a Context instance.
But can a Library project provide it's own assets for inclusion into the application? No.
I have created an "Assets" folder in the class lib and added a text file with build action "AndroidAsset", but from the app I could not access it via Assets.Open("file.txt");
Library projects cannot provide assets that will be included in the larger application. Java doesn't support this either, afaik.
Things to remember
1 Build Action is AndroidAsset (Properties)
2 Copy to output directory Do not copy (Properties)
3 Add the file to the Assets folder
var destinationPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "yourfilename.txt");
using (Stream source = Assets.Open("yourfilename.txt"))
using (var dest = System.IO.File.Create (destinationPath)) {
source.CopyTo (dest);
}
Sometimes this will still fail, monodroid bug. The best thing to do is check to see if the files were included correctly.
Load up Eclipse, in the device browser, you should see your simulator.
Go to the directory data/app/ download the file yourappname.apk
This is just a zip file, so change the extension to .zip and open the
zip archive. And goto the folder /assets and see if the file you are trying
to load is in there.
Also if you try to grab a file off a physical device your testing on, some allow it and other don't. This is easiest to test on the simulator.
It is possible to access the Assets files from a library:
var sourcePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
//var files = Directory.GetFiles(sourcePath);
var filePath = Path.Combine(sourcePath, "MyAssetFile.bin");
var content = File.ReadAllBytes(filePath);

How to refer file located in current application into file in SD card

I have a one script file in my current application.. The path for same look like this.
D:\myproj\Example\www\abc.js
while running my application in device it will download one file into my SDcard dynamically.
I need to parse my downloaded application and need to set this "abc.js" file path in this.
I can able to set path if my file is in SDCard , but dont know how to refer path which is in my current application..
If you have that file on SDCard, then the full path to it will be as follows:
file:///SDCard/myproj/Example/www/abc.js
ADDITIONAL INFO:
If your file is located in cod file, then there is a way, but it is not documented and it is not guaranteed that it will work on all devices and RIM OS versions.
Code below shows document.htm encapsulated in modulename.cod in BlackBerry browser.
BrowserSession session = Browser.getDefaultSession();
session.displayPage("cod://modulename/document.htm" );
Try to use cod://modulename/abc.js to specify path to your js file.
To reference an application embedded file (in this case an image file stored in images directory):
"file:///local/images/embedded_img.png"

How to access photos/video folder of iOS and copy file to applicaton folder using Marmalade

I need to open iphone folder like photos/videos.
I need to show content of that folder to user and when user selects a file from that I need to copy that particular file from that folder to my application folder.
Let me know what APIs I need to use for that.
Also let me know whether this is feasible or not using Marmalade.
have you tried looking at the s3eImagePicker example? under examples\s3e\s3eImagePicker

test a webworks blackberry app

I have four files (config.xml, index.html, scripts.js, and styles.css). The html has a canvas and a form for users input. I want to run on blackberry simulator (Torch version 6...). I create a zip file of all those files. Then create a bin folder. Now when I run the simulator and load the application, I have either blanc screen, either the following error: Resource does not exist.
Here is the config file code:
BlackberryTest
I had the same problem. You need to use local:/// prefix before the name of the local resource to access it.

Resources