2

I used until now next code to download required files:

DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
                                        request.setDescription("descriere");
                                        request.setTitle(mName);
                                        request.allowScanningByMediaScanner();
                                        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                                        request.setDestinationInExternalPublicDir("/MyDirectory/MyFiles", mFile);

But after I updated my android version to 10 I get now next error message:

java.lang.IllegalStateException: Not one of standard directories

for

request.setDestinationInExternalPublicDir("/MyDirectory/MyFiles", mFile);

Any solutions?

Edric
  • 24,639
  • 13
  • 81
  • 91
  • file is downloaded on Android/data and not on public directory –  Dec 27 '19 at 08:53
  • change compileSdkVersion and targetSdkVersion from 29 to 28 – Hadi Ahmadi Mar 20 '20 at 12:03
  • Thanx its working after change compileSdkVersion and targetSdkVersion from 29 to 28 – Mohamed Slimane Aug 05 '20 at 21:22
  • You will eventually move to targetsdkversion 29. Here is what you need to do. To Store file in External App-Specific Directory, Call `.setDestinationInExternalFilesDir(context, Environment.DIRECTORY_DOWNLOADS,fileName)` To Store file in External Public Directory, call `.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,fileName)` – learning-everyday Nov 09 '20 at 10:18

0 Answers0