Android Download Manager

I think I have a pretty simple question.

http://www.vogella.com/blog/2011/06/14/android-downloadmanager-example/

I read the tutorial at the above URL.

How to change the file path for upload?

Thanks at Advance

+5
source share
2 answers

You configure the DownloadManager.Request object with this information. In the tutorial, this object Requestis created and used in onClick().

For instance:

DownloadManager.Request req=new DownloadManager.Request(uri);

req.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI
                               | DownloadManager.Request.NETWORK_MOBILE)
   .setAllowedOverRoaming(false)
   .setTitle("Demo")
   .setDescription("Something useful. No, really.")
   .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,
                                      "test.mp4");

(above code from this sample project )

+17
source

The final line of the CommonsWare response indicates the destination. It just uses the usual download folder on the SD card, but you can also do this:

req.setDestinationInExternalPublicDir("/mnt/sdcard/Myfolder", "file_name.extension");
+5

All Articles