Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Download Manager setDestinationInExternalFilesDir

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?

like image 716
Aravind Srivatsan Avatar asked May 25 '13 13:05

Aravind Srivatsan


People also ask

How do I use Download Manager on Android?

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.


1 Answers

Add the permission in manifest file

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
like image 170
Grafritz Design Avatar answered Sep 25 '22 00:09

Grafritz Design