相关疑难解决方法(0)

在phonegap中写入和读取文件

我试过writing/reading一个文件phonegap+android,这里是设置:

$(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());
}
Run Code Online (Sandbox Code Playgroud)

但在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 …
Run Code Online (Sandbox Code Playgroud)

filesystems android cordova

6
推荐指数
1
解决办法
4万
查看次数

标签 统计

android ×1

cordova ×1

filesystems ×1