Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scoped Storage - Download folder access

I am targeting android 10 and I don't use android:requestLegacyExternalStorage. I use the DownloadManager to download into the download folder via: request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName). I listen to the download-complete-broadcast, extract the uri (file:///storage/emulated/0/Download/<name>.pdf) and open it in a pdf-reader via FileProvider. It works... why? Isn't it supposed to NOT work since android 10 and scoped storage? Why am I allowed to access files in the download-folder?

EDIT: Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).listFiles() lists all Files although the doc says:

To improve user privacy, direct access to shared/external storage devices is deprecated. When an app targets Q, the path returned from this method is no longer directly accessible to apps

like image 465
Kuno Avatar asked Sep 16 '25 09:09

Kuno


1 Answers

This was the solution:

If an app is installed with legacy external storage enabled, the app remains in this mode until it's uninstalled.

Changing the flag and restarting the app does not work.

Edit: Since a source was requested. The page changed since when I saw it first, so the quote is not 100% correct anymore, but still: In the blue box

like image 145
Kuno Avatar answered Sep 17 '25 23:09

Kuno