Javascript 为什么不是';t getFile()创建任何文件,即使我已将create标志设置为true?

Javascript 为什么不是';t getFile()创建任何文件,即使我已将create标志设置为true?,javascript,android,file,cordova,hybrid,Javascript,Android,File,Cordova,Hybrid,我正在尝试将一些数据写入一个文件,并将其保存在移动设备的内存中。我正在从事一个cordova项目,该项目安装了cordova插件文件。一切似乎都正常工作,没有错误,但没有创建任何文件,因此没有保存任何数据。。。 为什么即使我已经将create标志设置为true,getFile()也不创建任何文件 window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, success, fail); function success(fileSystem)

我正在尝试将一些数据写入一个文件,并将其保存在移动设备的内存中。我正在从事一个cordova项目,该项目安装了cordova插件文件。一切似乎都正常工作,没有错误,但没有创建任何文件,因此没有保存任何数据。。。 为什么即使我已经将create标志设置为true,getFile()也不创建任何文件

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, success, fail);

function success(fileSystem) {
    window.rootFS = fileSystem.root;
    window.rootFS.getFile("TestFile.txt", { create:true }, onSuccess, onFail); 
    function onSuccess() {
        //write something on the file 
    }
    function onFail(error) {
        //show error
    }

function fail(error) {
    alert("Failed to retrieve file: " + error.code);
}

我找到了一个解决方案:使用window.resolveLocalFileSystemURL而不是window.requestFileSystem。但是,我只能使用cordova.file.externalDataDirectory访问内部sd卡。只是cordova.file.dataDirectory提供了一个不存在的路径file:///data/data/... 以下代码证明适用于Android

window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function(dir) {
    console.log("got main dir",dir);
    dir.getFile("log.txt", {create:true}, function(file) {
        console.log("got the file", file);
        logOb = file;
        writeLog("App started");
    });
});