I am using the Download Manager and when I use
setDestinationInExternalFilesDir(this, Environment.DIRECTORY_DOWNLOADS, "example.ext");
the files are downloaded to Android/data/com.example.app/files/Download folder.
When I try
setDestinationInExternalPublicDir("/folder", "example.ext");
I get:
IllegalStateException: Cannot create directory mnt/sdcard/folder
.
I've set the WRITE_EXTERNAL_STORAGE permission too.
What am I doing wrong?
Once you are sure DownloadManager is available, you can do something like this: String url = "url you want to download"; DownloadManager. Request request = new DownloadManager. Request(Uri.
Add the permission in manifest file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With