我正在尝试使用phonegap cordova 1.5.0在android中编写一个文件。以下是代码段。这个片段在模拟器中工作正常,但是当我在我的Android手机上运行它直到gotFs()然后“失败错误代码”警告失败()弹出消息
“失败错误代码1”
这意味着它在行
失败
fileSystem.root.getFile("projectFileName", {create: create: true, exclusive: false}, gotFileEntry, fail);
代码段
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);
}
模拟器avd是2.3.3,我的设备有android 2.3.6。
答案 0 :(得分:2)
fileSystem.root.getFile("projectFileName", {create: create: true, exclusive: false}, gotFileEntry, fail);
到
fileSystem.root.getFile("projectFileName", {create: true, exclusive: false}, gotFileEntry, fail);