androidfilepathfilepathdownload-manager

Android Download Manager


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


Solution

  • 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)