Android DownloadManager illegalstateexception unable to create directory

后端 未结 2 1930
失恋的感觉
失恋的感觉 2020-12-17 20:04

I\'m making android app which is using DownloadManager. I want to download file into folder which I made. But this sources don\'t operate. And happen IllegalstateException.

相关标签:
2条回答
  • 2020-12-17 20:39

    What can I do?

    If you read the documentation for setDestinationInExternalPublicDir(), you will see that the first parameter is "the directory type to pass to getExternalStoragePublicDirectory(String)". That needs to be one of the constants defined on the Environment class, like Environment.DIRECTORY_DOWNLOADS. You are passing something else, which is not supported.

    0 讨论(0)
  • 2020-12-17 20:42

    Make sure you have

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    

    in your manifest.xml

    Also if you are using an emulator, make sure you created it with SD card storage. It's NOT created by default.

    0 讨论(0)
提交回复
热议问题