小编squ*_*tbe的帖子

如何使用Phonegap将文件下载到Android的下载文件夹?

我已使用Phonegap的File API成功将文件下载到我的Android手机.我想将文件下载到手机上的"下载"文件夹中.例如,如果从电子邮件下载附件,附件将转到"下载"文件夹.这是我的JS代码,它将文件下载到"file:// mnt/sdcard /":

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
  fileSystem.root.getFile('myfile.jpg', {
    create: true, 
    exclusive: false
  }, function(fileEntry) {
    var localPath = fileEntry.fullPath,
        fileTransfer = new FileTransfer();        
    fileTransfer.download(uri, localPath, function(entry) {
      console.log("download complete: " + entry.fullPath);
    }, function (error) {
    console.log('download error: ' + error.code);
    console.log("download error source " + error.source);
    console.log("download error target " + error.target);
  });
  }, downloadError);
}, downloadError);
Run Code Online (Sandbox Code Playgroud)

必须有一种方法来访问Downloads文件夹,因为我在其他应用程序中始终看到此功能.

android download cordova cordova-2.0.0

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

cordova ×1

cordova-2.0.0 ×1

download ×1