'How save file in emulated/0 (android 11)
I have been reading the documentation of the new way of saving files in android 11 and it is not clear to me ...
How could I save a file in / storage / emulated / 0 /?
My code only works on android 9 or lower (android 10 if I use preserveLegacyExternalStorage property in manifest, but on android 11 it doesn't work)
Solution 1:[1]
Android 11 introduces new approach to accessing storage, called Scoped Storage. Now for storing in any path you need new permission for Android 11: MANAGE_EXTERNAL_STORAGE
(doc HERE, some rich FAQ aritcle in HERE)
This will allow you to get access to whole storage, all subfolders, not only folder dedicated for your app, but be aware that not every app with this permission declared in manifest will be published in Google Play. So you should respect new policy and keep your files only in context.getExternalFilesDir("subdirName"), for reading some common types (images, videos, docs) you can still use MediaStore API
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |