cordova-file-plugin 文件存储在哪里

Where are files stored with cordova-file-plugin

我正在尝试在移动设备上创建 excel,我正在使用 android 进行测试,但它也应该适用于 iOS

我使用了文档中的以下代码 Documentation

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {
    console.log('file system open: ' + fs.name);
    fs.root.getFile("newPersistentFile.txt", { create: true, exclusive: false }, function (fileEntry) {

        console.log("fileEntry is file?" + fileEntry.isFile.toString());
        fileEntry.name == 'someFile.txt'
        fileEntry.fullPath == '/someFile.txt'
        fileEntry.createWriter(function (fileWriter) {

            fileWriter.onwriteend = function() {
                console.log("Successful file write...");
                fileEntry.file(function (file) {
                    var reader = new FileReader();

                    reader.onloadend = function() {
                        console.log("Successful file read: " + this.result);
                        //displayFileData(fileEntry.fullPath + ": " + this.result);
                    };

                    reader.readAsText(file);

                },);
            };

            fileWriter.onerror = function (e) {
                console.log("Failed file write: " + e.toString());
            };

            let dataObj = new Blob(['some file data'], { type: 'text/plain' });


            fileWriter.write(dataObj);
        });

    });

});

我试过为后面的几行更改前三行,结果相同

window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function (fs) {
    console.log('file system open: ' + fs.name);
    fs.root.getFile("newPersistentFile.txt", { create: true, exclusive: false }, function (fileEntry) { ...

我得到以下控制台日志

file system open: persistent    
fileEntry is file?true    
Successful file write...    
Successful file read: some file data

所以,文件已创建,我可以读取它,但我没有收到任何提示或其他内容,然后我导航到 Android/data/com.myapp.app/files 上的文件,然后我没有任何文件

似乎文件正在保存,但我看不到它们,但我可以通过 cordova-file-plugin 读取它们

我将目标文件夹更改为

let ruta = cordova.file.externalRootDirectory
let directoryRoute = "myApp";
            window.resolveLocalFileSystemURL(ruta, function (fs) {
                fs.getDirectory(directoryRoute, { create: true }, function (fs2) {
                    fs2.getFile(fileName, { create: true, exclusive: false }
, function (fileEntry) { ...

with cordova.file.externalRootDirectory 如果不存在用于保存我的应用程序文档的文件夹,我正在创建,这适用于 android,可能 iOS

我会在几天后更新 iOS 的答案,以防对某人有所帮助