如何在Cordova android应用程序的根目录下而不是应用程序数据目录中写入文件?

时间:2019-01-09 09:23:23

标签: android cordova

我正在构建Cordova android应用程序,并使用cordova-plugin-file在本地系统上写入文件。我正在使用的代码如下:

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());
        writeFile(fileEntry, null);

    }, onErrorCreateFile);

}, onErrorLoadFs);

文件newPersistentFile.txt将在app数据目录中创建。如何将文件写入系统根目录,例如/DownloadsNotifications等?

1 个答案:

答案 0 :(得分:0)

您要查看cordova.file目录(请参见docs)。

因此下载:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<img src="https://static.independent.co.uk/s3fs-public/thumbnails/image/2017/09/12/11/naturo-monkey-selfie.jpg?w968h681">
相关问题