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时,手机应用程序中的此功能会将其保存在我想要的位置?保存的文件将在根文件夹中可用。如果答案有用,请接受。