I need to create an android app to download a file when we give the url of the file and after press a button.I tried the steps on cordova file transfer page and also some stacks like Here but its not working. Here is my code for download in home.ts file
download() {
this.presentToast('started');
this.loader.present();
const fileTransfer: FileTransferObject = this.transfer.create();
const url = 'http://www.africau.edu/images/default/sample.pdf';
fileTransfer.download(url, this.file.dataDirectory
+'file.pdf').then((entry) => {
console.log('download complete: ' + entry.toURL());
this.presentToast('download complete:' + entry.toURL());
this.loader.dismiss();
}, (error) => {
// handle error
this.presentToast(error);
this.loader.dismiss();
});
}