Home » Java » java – Environment.getExternalStoragePublicDirectory() in Android 10-Exceptionshub

java – Environment.getExternalStoragePublicDirectory() in Android 10-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment


how can i get


in android 10

this method:


is deprecated is there a alternativ way to get or can i use
hardcodet path or is this not recommendet ?

How to&Answers:

See answer in https://stackoverflow.com/a/59873203/2373819 you will not by default to be able to use file paths outside of you App’s private directories, you need to use Storage Access Framework

The blog https://commonsware.com/blog/2020/01/11/scoped-storage-stories-diabolical-details-downloads.html has some good details on Download’s

With Download manager you don’t have to precheck that it exist’s just try and download it and then handle the status result that it failed because it already exists.


To improve user privacy, direct access to shared/external storage devices is deprecated. When an app targets Build.VERSION_CODES.Q, the path returned from this method is no longer directly accessible to apps.Apps can continue to access content stored on shared/external storage by migrating to alternatives such as Context#getExternalFilesDir(String), MediaStore, or Intent#ACTION_OPEN_DOCUMENT.