我試圖writing/reading
一個文件中phonegap+android
,這裏是設置:寫入和讀取文件中的PhoneGap
$(document).ready(function() {
document.addEventListener("deviceready", deviceready, true);
$(document).bind("deviceready", function(){
//writeFile();
//readFile();
});
});
function deviceready() {
writeFile();
readFile();
}
// This is just to do this.
function readFile() {
var d = navigator.file.read('/sdcard/foo.xml', success(), fail());
console.warn(d);
}
function writeFile() {
navigator.file.write('/sdcard/foo.xml', "This is a test of writing to a file",
success(), fail());
}
但在模擬器的Android 2.2,我得到了以下錯誤消息:
08-06 14:21:29.428: INFO/Web Console(936): Error in success callback: Network Status1 = TypeError: Result of expression 'navigator.file' [undefined] is not an object. at file:///android_asset/www/phonegap.0.9.6.js:649
什麼可能會丟失,什麼可以嘗試?
可能定),您使用的成功(),而不是你的呼叫成功背部同樣爲不合格(要失敗 –