2013-02-16 88 views
0

我發現我的設備的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卡,我想下載我的文件dirrectly功能至極下載文件在我的應用程序。

在網絡/數據單項

,但我不知道真的如何做到這一點

感謝

回答

1

不幸的是,WWW文件夾是隻讀的,你不能寫它。您只能寫入文件系統。

+0

好的,謝謝你的幫助 – Ajouve 2013-02-16 14:42:28