0

i have used the below code to download a video from server in android studio and it works correctly , but when i search the video in my device i cant find it anywhere ... where does it save and how can i change destination directory on "internal storage"?

private DownloadManager downloadManager;

btn_download_video.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
            Uri uri = Uri.parse(urlVideo);
            DownloadManager.Request request = new DownloadManager.Request(uri);
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
            request.setDestinationInExternalFilesDir(Video_detail_Activity.this, Environment.DIRECTORY_DOWNLOADS, videoName);
            Long reference = downloadManager.enqueue(request);

        }
 });

i used below permissions in my project too:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Sanoop Surendran
  • 3,484
  • 4
  • 28
  • 49
M.A.R
  • 87
  • 2
  • 8

1 Answers1

-2

thanks for helping ... as pskink said i changed

request.setDestinationInExternalFilesDir(Video_detail_Activity.this, Environment.DIRECTORY_DOWNLOADS, videoName);

to

request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS.toString(), videoName+".mp4");

and now i can see downloaded file in "Download" folder.

M.A.R
  • 87
  • 2
  • 8