Android Download Manager

Mich picture Mich · Jun 6, 2012 · Viewed 16.5k times · Source

I think i have a rather simple question.

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

I have been following a tutorial in the above url.

How do I change the filepath for downloads?

Thanks in Advance

Answer

CommonsWare picture CommonsWare · Jun 6, 2012

You configure the DownloadManager.Request object with that sort of information. In the tutorial, that Request object is created and used in onClick().

For example:

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 is from this sample project)