- 04-10-2012, 10:59 PM
Thread Author #1
save/read from file using html5?
does anyone know how to read or write files in html5? Either or is good I just want to learn it. If someone could give me some barebones code itd be good. Idealy itd be save/read on the pb. I know this forum isnt roamed as much but id like to see if anyone could help me out here. Thanks!
Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage & twitter account - 04-12-2012, 05:14 PM #2
The documentation here:
https://bdsc.webapps.blackberry.com/...ry.io.dir.html
Should be all you need. - 04-12-2012, 11:45 PM
Thread Author #3
honestly ive been over that and I really dont even understand how it is invoked.
Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage & twitter account - 04-13-2012, 04:48 PM #4
I don't know what your having trouble with? Here's some code that may help:
Make sure that you include these in your config.xml file:
Write some data to a file:Code:<feature id="blackberry.io.file" /> <feature id="blackberry.utils" />
Read from a file:Code:<script> // Where to you want to save the file? var filePath = "file:///store/home/user/myfile.txt"; // What do you want to save in the file? var data_to_save = "This string has everything that I want to write to the file"; // Make a blob to write to a file from your string var blob_to_write = blackberry.utils.stringToBlob(data_to_save); // Write the blob to the file blackberry.io.file.saveFile(filePath, blob_to_write); </script>
Code:<script> // What file do you want to read from? // var filePath = "file:///store/home/user/myfile.txt"; // Read data from the file (asynchronous) // blackberry.io.file.readFile(filePath, callback_when_read); // If you want to read the data synchronously instead: // // blackberry.io.file.readFile(filePath, callback_when_read, false); // The following function (specified in your call to readFile) is called // when the file has been read. function callback_when_read(filePath, fileData) { // Do whatever you want with the file // // filePath = path of file that was read // fileData = a blob containing the contents of the file // (you can name those parameters whatever you want, // but you need to have both!) // You want a string and not a blob? var myData = blackberry.utils.blobToString(fileData); } </script>Thanked by 2:ignites (04-14-2012), Superfly_FR (06-29-2012)
- 06-28-2012, 01:57 PM
Thread Author #6
Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage & twitter account - 06-30-2012, 03:05 PM #7Developer of; Crackberry Forums Reader app -> Crackberry Forum App (NON-ANDROID)
Playbook + BB10 DEV , APPS ON REQUEST PLEASE PM ME
bbUI.js expert -- Need HELP ? Just PM me ! Blackberry Playbook 64GB
WEBWORKS APP DEVELOPER & APP CONVERTER + SIGNING - 06-30-2012, 06:53 PM #8
What error are you getting? (Use try/catch)
Is this on phones or tablets? (That makes a difference right now. You'll need an extra tag in your config.xml <rim:permit>access_shared</rim:permit> on tablets. Also, make sure you have the most recent SDK for tablets as the whole file API wasn't implemented in earlier versions and you used to need to use WebKitBlobBuilder to make your blob.)
Make sure your path is correct. (take a look at blackberry.io.dir.appDirs to help if you're not sure)
See this for more info:
https://developer.blackberry.com/htm...y.io.file.html - 07-01-2012, 10:51 PM
Thread Author #9
I forgot what i got when i tried and catch. I dont think this is an access_Share issue because I could save once but not again unless i delete the file. I can read the file too, its just an error if I try to save and the file already exists. I;ll try and get back to you.. but thats odd and no one at rim is responding to me too. I have the latest version of WW.
Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage & twitter account - 07-03-2012, 09:07 PM #10
Weird. Well, I tried and couldn't get an error even though I did manage to reproduce the not-overwriting thing (os6). Here's a stupid fix that should work everywhere:
Code:// Before you save ... delete the file // if (blackberry.io.file.exists(filePath)) { blackberry.io.file.deleteFile(filePath); } - 07-06-2012, 01:07 AM
Thread Author #11
Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage & twitter account

Reply
ermit>access_shared</rim
















![How to run almost any Android 2.3.3 app on BlackBerry 10 [Mac Guide] How to run almost any Android 2.3.3 app on BlackBerry 10 [Mac Guide]](http://cdn.crackberry.com/sites/crackberry.com/files/styles/w100h100crop/public/article_images/2013/06/q10-playbook-devmode.jpg?itok=JOvs0jQ8)