我已经使用Phonegap的File API成功将文件下载到我的
Android手机.我想将文件下载到手机上的“下载”文件夹中.例如,如果从电子邮件下载附件,附件将转到“下载”文件夹.这是我的JS代码,它将文件下载到“file:// mnt / sdcard /”:
window.requestFileSystem(LocalFileSystem.PERSISTENT,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);