Needs to enable storage permission manually in android device while downloading file ( IONIC 2 cordova-file-plugin)


I am using cordova file plugin’s download method to download file on android device.
I get file download successful message only if I enable the storage pemission by going to Settings>> Apps>> Myapp >> permission > storage

here is code I used

downloadImage(image) {

this.platform.ready().then(() => {

  const fileTransfer: TransferObject = this.transfer.create();

  const imageLocation = `${cordova.file.applicationDirectory}www/assets/img/${image}`;, this.storageDirectory + image).then((entry) => {

    const alertSuccess = this.alertCtrl.create({
      title: `Download Succeeded!`,
      subTitle: `${image} was successfully downloaded to: ${entry.toURL()}`,
      buttons: ['Ok']


  }, (error) => {

    const alertFailure = this.alertCtrl.create({
      title: `Download Failed!`,
      subTitle: `${image} was not successfully downloaded. Error code: ${error.code}`,
      buttons: ['Ok']







Use Ionic Diagnostic


Thanks Marcuslll. As I am new to IONIC, can you please suggest me to which function should I use in my case?


Yeah sure

//User gave permission 
//Handle error

What this will do it will check if the app already have the permission if it does it will do nothing
if it doesn’t have permission it will ask the user to give permission


MarcusIII Thanks a lot. It worked :slight_smile:


where put this function please tell me