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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With