Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Cordova或phonegap:保存文件捕获器_Javascript_Android_Ios_Cordova - Fatal编程技术网

Javascript Cordova或phonegap:保存文件捕获器

Javascript Cordova或phonegap:保存文件捕获器,javascript,android,ios,cordova,Javascript,Android,Ios,Cordova,我现在用javascript开发了一个应用程序,我想使用cordova或phonegap使我的代码适应android、Iphone等。但在我的应用程序中,我使用以下功能保存我的文件: function save(){ var myFileJSON = JSON.stringify(myFile); try{ var blob = new Blob([myFileJSON], {type: "text/plain;charset=utf-8"});


我现在用javascript开发了一个应用程序,我想使用cordova或phonegap使我的代码适应android、Iphone等。但在我的应用程序中,我使用以下功能保存我的文件:

function save(){
    var myFileJSON = JSON.stringify(myFile);
    try{
        var blob = new Blob([myFileJSON], {type: "text/plain;charset=utf-8"});
        saveAs(blob, "myFileJSON.txt");
    } catch (e){
        console.log('bug');
    }
}
因此,我想用我的手机应用程序将我的文件保存在一个特定的文件夹中。我可以捕获save事件并立即重定向路径吗

function saveCourseToFile() {
   console.log("checkpoint 1");
   window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFSSuccess, onFSError);
}
function onFSSuccess(fileSystem) {
   console.log("checkpoint 2");
   console.log("Opened file system: " + fileSystem.name);
   fileSystem.root.getFile("readme.txt", {create:true, exclusive:false}, gotFileEntry, onFSError);
}
function gotFileEntry(fileEntry) {
   console.log("checkpoint 3");
   fileEntry.createWriter(gotFileWriter, onFSError);
}
function gotFileWriter(writer) {
   writer.onwrite = function(evt) {
      console.log("checkpoint 4: write success!");
   };
   writer.write("test test test");
}

您也可以查看链接以供参考。

因此,当我用我的js调用save时,手机应用程序中的此功能会将其保存在我想要的位置?保存的文件将在根文件夹中可用。如果答案有用,请接受。