Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't require WRITE_EXTERNAL_STORAGE on Android Q and higher

I use DownloadManager to download a photo and save it to external pictures directory:

.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES, File.separator + filename)

Marshmallow requires WRITE_EXTERNAL_STORAGE (as expected) but on Android Q and higher it works fine without the permission. Why is it so? Is it because of scoped storage?

like image 636
Serhii K. Avatar asked Mar 20 '20 18:03

Serhii K.


Video Answer


1 Answers

Android doc:

Android defines the following permissions for read-and-write access to external storage: READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE.

On earlier versions of Android, apps needed to declare these permissions to access any file outside the app-specific directories on external storage. More recent versions of Android rely more on a file's purpose than its location for determining an app's ability to access that file. This purpose-based storage model improves user privacy because apps are given access only to the areas of the device's file system that they actually use.

To give users more control over their files and to limit file clutter, apps that target Android 10 (API level 29) and higher are given scoped access into external storage, or scoped storage, by default. Such apps have access only to the app-specific directory on external storage, as well as specific types of media that the app has created.

For more

like image 166
Kasım Özdemir Avatar answered Oct 24 '22 05:10

Kasım Özdemir