I am trying to write a file in android using phonegap cordova 1.5.0. Below is the code snippet. This snippet is working fine in simulator but when I run this on my android mobile it goes till gotFs() then "fail error code" alert of fail() pops up with message
"fail error code 1"
that means it is failing at line
fileSystem.root.getFile("projectFileName", {create: create: true, exclusive: false}, gotFileEntry, fail);
.
code snippet
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fS) {
fileSystem = fS;
fileSystem.root.getFile("projectFileName", {create: create: true, exclusive: false}, gotFileEntry, fail);
}
function gotFileEntry(fE) {
fileEntry = fE;
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
.......... file writing code.
}
function fail(error) {
alert('fail error code = '+error.code);
alert('error '+error);
console.log(error.code);
}
The simulator avd is 2.3.3 and my device has android 2.3.6.