0

Good evening, I am developing an application in phonegap and I need to download images on the SD card, but I get an error, I hope someone can help me, thanks

<a href="#" onclick="downloadImagess()">Download File</a>
 function downloadImagess(){
  alert("download just started.");
   var url = 'https://image.freepik.com/vector-gratis/glifos-egipto_23-2147522976.jpg'; 
var filename= 'Egipto';
try{
    var ft = new FileTransfer();
    ft.download(
       url,
       target_directory + filename, 
       function(entry) {
          alert("download complete!:"); //path of the downloaded file 
       },
       function(error) {
          alert("download error" + error.code);
          //alert("download error" + JSON.stringify(error));
       }
   );
 }
 catch (e){
   //alert(JSON.stringify(e));
  }

}

Also left the image of the error http://fotos.subefotos.com/850cbc202b844108ba7f2bddba098856o.png

1 Answers1

1

If the target directory that you are trying to save to is your own app specific directory you should be able to save data to it without requiring any explicit WRITE_EXTERNAL_STORAGE permission.

From Lollipop, if you are trying to store data in SD Card in folders other than the one owned by your app, you need users to specify that permissions for your app through Storage Access Framework.

This post covers this in more detail: How to use the new SD card access API presented for Android 5.0 (Lollipop)?

Community
  • 1
  • 1
somesh
  • 2,509
  • 3
  • 16
  • 24