Showing posts with label download song from server. Show all posts
Showing posts with label download song from server. Show all posts

Monday, 28 March 2016

How to download file from server in android


android.jpg

It is recommended that whenever one wants to download any file from server whether it is song or any image , it must perform in the background either by using asynctask or using a thread.
Here, we are using Asynctask:-
  1. /**
  2. * Downloading file in background thread
  3. */
  4. boolean download = true;

  5. @Override
  6. protected String doInBackground(String... params)
  7.    {
  8.       File SDCardRoot = Environment.getExternalStorageDirectory(); // location where you want to store
  9.       File directory = new File(SDCardRoot, "/my_folder/"); //create directory to keep your downloaded file
  10.       if (!directory.exists())
  11.       {
  12.         directory.mkdir();

Here is not the end. Read the full article about How to download file from server in android at Findnerd.