1

I am downloading videos from the server using Android DownloadManager. I want to give a name to each video myself. By default the name of videos downloadfile-6.bin.

String servicestring = Context.DOWNLOAD_SERVICE;
DownloadManager downloadmanager;
downloadmanager = (DownloadManager) getSystemService(servicestring);
Uri uri = Uri.parse(links.get(0));
DownloadManager.Request request = new DownloadManager.Request(uri);
Long reference = downloadmanager.enqueue(request);

Suggestion will be appreciated.

Raktim Biswas
  • 4,011
  • 5
  • 27
  • 32
M.ArslanKhan
  • 3,640
  • 8
  • 34
  • 56

1 Answers1

5

You can set it via DownloadManager.Request object using setDestinationInExternalFilesDir(...) or setDestinationInExternalPublicDir(...). See the last line:

request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
       .setAllowedOverRoaming(false)
       .setTitle("DownloadTitle")
       .setDescription("DownloadDesc")
       .setDestinationInExternalPublicDir("/mypath", "filename.jpg");

Sources:

Ugurcan Yildirim
  • 5,973
  • 3
  • 42
  • 73