Downloading files using Download Manager in Android

Save

Download Manager is a system service which optimizes the handling of long-running downloads in the background. If you want to download large files/streaming you can use  Android Download Manager.  The download manager handles HTTP connections, monitors connectivity changes, reboots, and ensures each download completes successfully.

Add the following permission to your AndroidManifest.xml file:

First, we will have to generate URI from URL.

On click of the  button, write the below mentioned code.

In the above code, We are passing a request to the Download Manager with the download file URL, Title and Description to be shown in notification bar etc. We can also specify whether the download should happen over wifi or cellular or both.

Thanks for reading.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


6 comments

  • franklyn
    manager.enqueue(request);
    where did this come from not working
    • saumya dubey (Moderator)
      Thanks for reporting the issue.
      Please check the updated code – downloadManager.enqueue(request);
  • Hazem
    Thanks, does this works for youtube videos as well?
    And what about MP3 files?
    • anchit (Moderator)
      Hey,

      Sorry this will not work for youtube urls.

      The above solution will work only with the urls that support downloading the video.

      Mp3 files or any files can be downloaded if the url is correct and the url supports the download functionality.

  • Shokirov
    download empty file my application but code is like code which it
    • anchit (Moderator)
      Hey there,

      Are you sure that the url you have added is of a proper file ?

  • css.php

    Excellent work, fast, good quality and understood the brief perfectly! Quick responses developing the project and very good cooperation. I suggest to anyone.

    Stathis Plakidas

    Stathis Plakidas

    Talk to Sales

    Global

    Live Chat
    Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home