File 在phonegap应用程序中下载文件

File 在phonegap应用程序中下载文件,file,cordova,File,Cordova,我找到了一个将文件下载到我的设备sd卡的功能 application.downloadFile = function(file, callback) { window.requestFileSystem( LocalFileSystem.PERSISTENT, 0, function onFileSystemSuccess(fileSystem) { fileSystem.root.getFile( "dummy.html&qu

我找到了一个将文件下载到我的设备sd卡的功能

application.downloadFile = function(file, callback)
{
    window.requestFileSystem(
    LocalFileSystem.PERSISTENT, 0, 
    function onFileSystemSuccess(fileSystem) {
        fileSystem.root.getFile(
        "dummy.html", {create: true, exclusive: false}, 
        function gotFileEntry(fileEntry) {
        var sPath = fileEntry.fullPath.replace("dummy.html","");
        var fileTransfer = new FileTransfer();
        fileEntry.remove();

        fileTransfer.download(
            application.api+file,
            sPath + "assas.json",
            function(theFile) {
                console.log("download complete: " + theFile.toURI());
                application.dataPath = theFile.toURI();
                callback();
            },
            function(error) {
                console.log("download error source " + error.source);
                console.log("download error target " + error.target);
                console.log("upload error code: " + error.code);
            }
          );
        });
    });
};
代码运行良好,但它将代码下载到我的sd卡中,我想直接在我的应用程序中下载我的文件

www/datas


但我真的不知道该怎么做。

不幸的是,WWW文件夹是只读的,您无法写入它。您只能写入文件系统