How to download a file in Android

Today in this post, I am going to share the code that I use in my android applications to support downloading of file. There are many ways you can use to download a file. For example you can use Async task and read the file stream to save it in device storage, you could also use a Service to download the file. But in my example I will show you the code that uses DownloadManager class.


The code sample using DownloadManager class is as follows:

Now to use this function
downloadFile(context, "http://i.imgur.com/DvpvklR.png", 
"File download",
"File is being downloaded...");
Hope this helps you.

Comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete

Post a Comment

Popular posts from this blog

Automate file upload in Selenium IDE

How To Install and Configure Nextcloud