Reputation: 1721
I m using below code, but do not know where files are being downloaded. None of file stored at given path. What correction is required in code. Code is creating folder in beginning.
String path = Environment.getExternalStorageDirectory().getPath() + "/Myapp/Videos";
System.out.println(path);
File folder = new File(path);
if (folder.canExecute()) {
System.out.println("Video Folder Found");
} else {
folder.mkdirs();
}
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDescription("Selected Video is being downloaded");
request.allowScanningByMediaScanner();
request.setTitle("Downloading Video");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalFilesDir(mContext, null, title + ".mp4");
DownloadManager manager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
return null;
Upvotes: 1
Views: 4477
Reputation: 171
This is how I solve my problem
request.setDestinationInExternalFilesDir(context, "/path/", "MyFile.txt");
Upvotes: 0
Reputation: 1058
simply use
request.setDestinationInExternalPublicDir("/Path", "test.mp4");
Upvotes: 6