I am new to using downloadmanager in android. I am using genymotion emulator.
I am trying to download an mp3 file using downloadmanager. I want to know where the file is stored after download.
Environment.getExternalStorageDirectory()
it shows /storage/emulated/0. its the shared "external storage"
I also checked
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
it points to /storage/emulated/0/Download
. The mp3 file in not there.
I also checked /storage/emulated/0/Android/data/com.simha.sacredindaapp. The mp3 file is not there.
My code for downloading the mp3 file is:
DownloadManager downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
Uri uri = Uri.parse("http://audio.iskcondesiretree.com/02_-_ISKCON_Swamis/ISKCON_Swamis_-_R_to_Y/His_Holiness_Radhanath_Swami/Lectures/00_-_Year_wise/Devotional_Nectar_-_2016/2016-01-31_Various_-_Vrindavan_is_Perceived_by_Our_Consciousness-For_Ukraine_Devotees_-_Radhanath_Swami.mp3");
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDescription("My Download").setTitle("Notification titile");
downloadManager.enqueue(request);
you need to set a destination directory.
DownloadManager downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
Uri uri = Uri.parse("http://audio.iskcondesiretree.com/02_-_ISKCON_Swamis/ISKCON_Swamis_-_R_to_Y/His_Holiness_Radhanath_Swami/Lectures/00_-_Year_wise/Devotional_Nectar_-_2016/2016-01-31_Various_-_Vrindavan_is_Perceived_by_Our_Consciousness-For_Ukraine_Devotees_-_Radhanath_Swami.mp3");
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDescription("My Download").setTitle("Notification titile");
// change the name file and your current activity.
request.setDestinationInExternalPublicDir(MainActivity.this, Environment.DIRECTORY_DOWNLOADS, "test.jpg");
downloadManager.enqueue(request);