Downloading Audio file from a URL

Updated 22 April 2017

Save

Downloading an audio file from a URL is a very common process and most of the app have this functionality. It is really simple to download an audio from a URL and for that, you need to create an object of DownloadManager and enqueue the DownloadManager.Request object into it.

As you can see in the above code segment a download service is taken and an object of DownloadManager.Request is created with the file URI. You can use the setTitle and setDescription function to the title and description respectively which will be displayed when the notification bar is expanded.

function setDestinationInExternalPublicDir is used to set the destination of the file in the external memory. Environment.DIRECTORY_DOWNLOADS defines that the file will be stored in the downloads directory.

After creating the request all you need to do is use the enqueue function of the DownloadManager to start the download.

 

Thank you very much, this is Vedesh Kumar signing off.

author
. . .

Leave a Comment

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


Be the first to comment.

Start a Project


    Message Sent!

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

    Back to Home