Error Code: 1 When executing getFile() on Blackberry OS 6

  • 2
  • Problem
  • Updated 6 years ago
  • Not a Problem
In blackberry OS 6, the getFile method in the below case calls errorCallback (instead of the successCallback) and returns the error code 1 (which I believe is FileError.NOT_FOUND_ERR). This works in windows phone 7, iOS, and Android.

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
fileSystem.root.getFile('accountinfo.txt', { create: true }, function (fileEntry) {
fileEntry.createWriter(function (writer) {
writer.onwrite = function (event) {
};

writer.write(JSON.stringify(jsonObject));
},
function (error) {
alert(target + ' - CreateWriter: ' + error.code);
});
},
function (error) {
alert(target + ' - GetFile: ' + error.code);
});
},
function (error) {
alert(target + ' - Request: ' + error.code);
});

Here are the contents of the fileSystem.root property in JSON format:
{"isFile":false,"isDirectory":true,"name":"","fullPath":"file;///store","filesystem":null}

Please help!
Photo of kevinbusch

kevinbusch

  • 33 Posts
  • 1 Reply Like
  • sad

Posted 8 years ago

  • 2
Photo of Alan Neveu

Alan Neveu, Champion

  • 213 Posts
  • 11 Reply Likes
This might help you, not sure... I tried to get the PhoneGap folks to recognize this bug for a long time but their phones worked and the problem was only evident on my devices. So I coded around it and gave up trying! This is my workaround...

function fixBBFileEntryFullPath(fileEntry) {
//for some reasons PhoneGap 1.6.1 and higher has file:///SDCardfilename.txt for the fullPath
//and it should have a slash between SDCard and filename, and it turns out it is not readonly
//so replacing it with a slash between just, um, works. Lovely.
//it may also have "store" instead of "SDCard", so we have to replace that too.
if (isBlackBerry() == true) {
if (fileEntry.fullPath.indexOf("SDCard") > 0) {
if (fileEntry.fullPath.indexOf("SDCard/") == -1) {
fileEntry.fullPath = fileEntry.fullPath.replace("SDCard", "SDCard/");
}
}
if (fileEntry.fullPath.indexOf("store") > 0) {
if (fileEntry.fullPath.indexOf("store/") == -1) {
fileEntry.fullPath = fileEntry.fullPath.replace("store", "store/");
}
}
}
}
Photo of kevinbusch

kevinbusch

  • 33 Posts
  • 1 Reply Like
Thanks for the info, Alan. Unfortunately I think your problem is a little different than mine. I am trying to get the fileEntry object (by getting the code to execute successCallback from the getFile method). Instead, the getFile method is firing the failCallback.
Photo of kevinbusch

kevinbusch

  • 33 Posts
  • 1 Reply Like
This behavior doesn't appear to be limited to OS 6.0. I was able to successfully run the application on the BB Torch 9860 OS 7.0 simulator. All other simulators I tested on failed (Porsche 9981 OS 7.0, Porchse 9981 OS 7.1, Torch 9800 OS 6.0, Curve 9330 OS 6.0).

If this continued to be a bug for PhoneGap with Blackberry, we're going to have to consider pulling the plug on PhoneGap. This is a HUGE capability bug.

Here is a link to the BB simulator downloads.
http://us.blackberry.com/sites/develo...

My app ID is 217694. I can give log in credentials if necessary.

Thank you!
Photo of Jonathan Smirnoff

Jonathan Smirnoff

  • 3 Posts
  • 0 Reply Likes
I had the same problem and I fixed loading the SDCard in the simulation.
Photo of Gustavo Molina

Gustavo Molina

  • 2 Posts
  • 0 Reply Likes
I got the same problem I think and I find out that the issue is the directory where the files are being saved. When I do the "fileTransfer.download" I use this "fileSystem.root.fullPath" to get the path where the files is going to be saved.
On the success, when I try to read the file, I got an error that says that the file is not found, but the problem is not that the file does not exist, the problem is that it is looking the file in the wrong directory. For some reason it is not saving it in "fileSystem.root.fullPath", it changes the directory for some reason to Device, if the phone does not have the sdcard or to Media Card if the sdcard is in.
I'm not sure how to fix this, or if there is some way to solve it
Photo of Zahir

Zahir

  • 3500 Posts
  • 40 Reply Likes
Hi all,

Would you mind updating us on your current progress?
Thanks.
Photo of Zahir

Zahir

  • 3500 Posts
  • 40 Reply Likes
Due to the thread inactivity, this issue is now closed.
Create a new issue if you have any other problem with PhoneGap Build.
Thanks

This conversation is no longer open for comments or replies.