Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.SecurityException: Unsupported path path/path/JPEG_5e3bbe8ed6c75_24741_.jpg

This is not working on Some Devices. In Samsung Device they not allow to download file using Download manager. I have already define permission in the manifest and also get RunTime Permission.

DownloadManager downloadManager = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setTitle("");
request.setDescription("");
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationUri(Uri.fromFile(imageFile));
request.setMimeType("*/*");
downloadManager.enqueue(request);
like image 673
Bhavin Parghi Avatar asked Oct 16 '22 06:10

Bhavin Parghi


1 Answers

Use this

setDestinationInExternalFilesDir(
            context.applicationContext,
            Environment.DIRECTORY_DOWNLOADS,
            ""
        )
like image 188
Shaon Avatar answered Nov 02 '22 06:11

Shaon