Caused by: java.lang.IllegalStateException: Unable to create directory in Android 6.0 devices

后端 未结 3 1250
野趣味
野趣味 2021-01-18 09:17

I have to store the download the image from the url using DownloadManager and store it into the sdcard with my own directory like \"xyz\". This is my code

Fi         


        
3条回答
  •  孤街浪徒
    2021-01-18 10:00

    Caused by: java.lang.IllegalStateException: Unable to create directory: /storage/emulated/0/storage/emulated/0/xyz at android.app.DownloadManager$Request.setDestinationInExternalPublicDir(DownloadManager.java:538)
    

    Issue seems it be related with Android Runtime Permission introduced in Android 6.0

    When your app targeting is API Level 23 or higher, by default all the permissions are false. To resolve this, you have to request a permission dialog and approve the permission before using that into your app.

提交回复
热议问题