05-15-2011 01:13 PM
Hi,
I was wondering how to write files from a WebWorks app to the SD card or internal storage. Looking at the API there seems to be something that enables me to write to SD:
var filePath = "file:///SDCard/BlackBerry/Sample.txt";
var blob_data = blackberry.utils.documentToBlob(testData);
blackberry.io.file.saveFile(filePath, blob_data);
I also added the following to config.xml:
file:///SDCard/BlackBerry
Any idea why it isn't working?
By the way, what is a blob???
Regards
06-09-2011 07:56 PM
Did you figure this out yet?
06-09-2011 09:12 PM
Which OS version are you trying these calls?
BlackBerry 5.0, 6.0 or PlayBook?
BlackBerry 6.0 does not support the documentToBlob() function
06-10-2011 07:01 AM
I'm looking to do WebWorks for OS 6.0 and Playbook. I just heard that at least for Playbook the feature will be available in mid-June.
06-10-2011 07:06 AM
Yes, file I/O will be coming to WebWorks on PlayBook in a week or two. However, documentToBlob and blobToDocument are only supported on BB5
06-29-2011 09:05 PM
Ok, so I was trying to access a file in the Playbook simulator but it didn't work. The simulator is 1.0.1 and the SDK is the version released just a week or two ago.
The code is below:
var filePath = blackberry.io.dir.appDirs.app.storage.path + "/favorites.txt";
function onFileOpen(fullPath, blobData){
globalBlob = blobData;
alert(globalBlob);
}
alert(filePath);
if (blackberry.io.file.exists(filePath)) {
try{
blackberry.io.file.readFile(filePath,onFileOpen, true);
}catch(e){
alert(e);
}
}
else {
var globalBlob = "TEST";
blackberry.io.file.saveFile(filePath, globalBlob);
}
06-30-2011 05:46 PM
Looks like I found my answer:
This feature isn't supported yet!