【问题标题】:download images to SD card with phonegap使用 phonegap 将图像下载到 SD 卡
【发布时间】:2015-12-27 17:39:49
【问题描述】:

晚上好,我正在phonegap中开发一个应用程序,我需要将图像下载到SD卡上,但出现错误,希望有人能帮助我,谢谢

<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));
  }

}

还留下了错误的图片 http://fotos.subefotos.com/850cbc202b844108ba7f2bddba098856o.png

【问题讨论】:

    标签: android file cordova filesystems


    【解决方案1】:

    如果您尝试保存到的目标目录是您自己的应用程序特定目录,您应该能够将数据保存到其中,而无需任何明确的 WRITE_EXTERNAL_STORAGE 权限。

    在 Lollipop 中,如果您尝试将数据存储在 SD 卡中的应用程序所拥有的文件夹以外的文件夹中,则需要用户通过存储访问框架为您的应用程序指定该权限。

    这篇文章更详细地介绍了这一点: How to use the new SD card access API presented for Android 5.0 (Lollipop)?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-25
      • 2023-03-17
      • 2016-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多