无法下载到Android 4.3的外部存储?

时间:2015-07-17 02:58:14

标签: android

我从google驱动器上的链接下载了一些文件到我的外部
      存储在HTC Desire 610与Android 4.4版本所以一切都很好       但当我使用huwaei媒体垫与Android 4.3 api我发现该文件       没有写入我的外部存储空间。

那我怎么解决这个问题呢? 提前致谢

  public void download(String path,String url,Context cont) {

    DownloadManager.Request request = new  .Request(Uri.parse(url));
    Log.e("ondownload", url);
    request.setDescription("Menu");
    request.setTitle("Menu");
    request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI |DownloadManager.Request.NETWORK_MOBILE);  


    // in order for this if to run, you must use the android 3.2 to compile your app 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        request.allowScanningByMediaScanner();
    } 

    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);

    request.setDestinationInExternalFilesDir(MainActivity.this, Environment.DIRECTORY_DOWNLOADS, "Dave's Menu/Menu");

    // get download service and enqueue file 
    DownloadManager manager = (DownloadManager) cont.getSystemService(Context.DOWNLOAD_SERVICE);
    manager.enqueue(request);
    ringdialog();



}

这是我的日志:

07-17 05:07:31.882: W/System.err(27838): java.io.FileNotFoundException:
  /storage/emulated/0/Dave's Menu/Menu.json: open failed: ENOENT (No such 
 file or directory)
 07-17 05:07:31.882: W/System.err(27838):   at 
 libcore.io.IoBridge.open(IoBridge.java:409)
 07-17 05:07:31.892: W/System.err(27838):   at java.io.FileInputStream.
 <init>(FileInputStream.java:78)
 07-17 05:07:31.892: W/System.err(27838):   at 
 com.abonaga.davescafe.RssReader.readFile(RssReader.java:289)
 07-17 05:07:31.892: W/System.err(27838):   at  
 com.abonaga.davescafe.RssReader.Retrieve_jsonarray(RssReader.java:79)
 07-17 05:07:31.892: W/System.err(27838):   at 
 com.abonaga.davescafe.RssReader.getDaveitems(RssReader.java:66)

 07-17 05:07:31.892: W/System.err(27838):   at  
 com.abonaga.davescafe.RssReader.getLatestRssFeed(RssReader.java:62)
 07-17 05:07:31.892: W/System.err(27838):   at 
 com.abonaga.davescafe.Menu.newviews(Menu.java:48)
 07-17 05:07:31.892: W/System.err(27838):   at 
 com.abonaga.davescafe.Menu.onCreate(Menu.java:39)
 07-17 05:07:31.892: W/System.err(27838):   at    
 android.app.Activity.performCreate(Activity.java:5234)

 07-17 05:07:31.892: W/System.err(27838):   at 
 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

0 个答案:

没有答案