Android Downloadmanager Save To Download Folder
I'm using DownloadManager to download file, I wanted to put the downloads in the standard download folder so people could easily find them using file manager looking in the most ob
Solution 1:
Uri downloadLocation=Uri.fromFile(newFile(Environment.DIRECTORY_DOWNLOADS, filename));
That is not how you use Environment.DIRECTORY_DOWNLOADS
. That constant is for use with getExternalStoragePublicDirectory()
:
File dir=Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
dir.mkdirs();
Uri downloadLocation=Uri.fromFile(new File(dir, filename);;
Note that the directory may not exist yet, so you should call mkdirs()
yourself.
Also, what if they don't have external memory, just internal?
Practically all Android devices have external memory. External != removable. What the Android SDK refers to as "external storage" is what the user can access via the USB cable, and usually is on the same partition as "internal storage", in on-board flash memory.
Post a Comment for "Android Downloadmanager Save To Download Folder"