I am using Cordova FileTransfer object to download a file from a url to device.
var fileTransfer = new FileTransfer();
var path = cordova.file.dataDirectory;
fileTransfer.download(
fileUrl,
path + "/sample.pdf",
function(theFile) {
console.log("download complete: " + theFile.toURI());
alert("File downloaded to "+cordova.file.dataDirectory);
},
function(error) {
console.log(JSON.stringify(error));
}
);
In this case the file is downloaded to data/data/com.fileDemo/files/
(I am not sure whether download is success as I can't access this folder. Getting success message as download complete: file:///data/data/com.fileDemo/files/sample.pdf
).
How can I use the same method to download a file to "Downloads" folder of the android device?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…