I have successfully downloaded a file to my Android phone using Phonegap's File API. I would like to download the file to the Downloads folder on my phone. For example, if you download an attachment from an email, the attachment goes to your Downloads folder. Here is my JS code, which downloads the file to "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);
There has to be a way to access the Downloads folder, because I see this functionality all of the time in other apps.