To protect user data and reduce the amount of space consumed by apps, Android 10 introduced changes to the behavior of the external storage permission. Android 11 Developer Preview continues this effort while adding improvements designed to help developers adapt to the changes.

Most of the apps published on Google Play that request the storage permission do so for common reasons, such as saving files on SD cards or reading media files. These apps are able to save a large number of files on disk that remain after the app is uninstalled. They can also read potentially sensitive files from other apps.

With Android 10, we adjusted how storage permission works, to give apps the access they need. This also limits file clutter by encouraging apps to save files in their designated directories which are cleared when an app is deleted.

The storage changes in Android 10 followed three basic principles:

Better attribution : The system knows what files belong to which apps, making it easier for users to manage their files. And when an app is uninstalled, the content that it created shouldn’t stay unless the user wants it to

: The system knows what files belong to which apps, making it easier for users to manage their files. And when an app is uninstalled, the content that it created shouldn’t stay unless the user wants it to Protecting app data : When an app writes app-specific files to external storage, these files should not be visible to other apps

: When an app writes app-specific files to external storage, these files should not be visible to other apps Protecting user data: When the user downloads files, such as sensitive email attachments, these files should not be visible to most apps

Apps targeting Android 10 can contribute to their own external app directories and organize media collections (audio, video, images, and downloads) without needing to request the storage permission. The Storage permission only allows apps to read media files shared by other apps in the audio, video, and image collections. However, it does not give read access to files in the Downloads collection that the app did not create. The only way for apps to access non-media files created by other apps in Android 10 is by using the document picker provided by the Storage Access Framework.

In Android 11, we will continue to improve the developer experience related to Scoped Storage by introducing the following changes.

Media store improvements

Android 10 required that all apps use MediaStore APIs to access photos, videos, and music files. This will continue to be our recommendation. However, we understand that many apps depend heavily on APIs that use file paths, including third-party libraries, that cannot easily switch to using file descriptors. So in Android 11, APIs and libraries that use file paths will be enabled again. Your app can use the requestLegacyExternalStorage manifest attribute to ensure compatibility for users running Android 10.

Under the hood, I/O requests using file paths are delegated to the MediaStore API. This redirection has some performance impact when used to read files outside of your isolated storage. Further, using file paths does not provide any feature benefits over the MediaStore APIs, hence our strong recommendation to use the MediaStore directly.

On Android 10, users were required to confirm each file that an app requested to edit or delete. With Android 11, apps can request to modify or delete several media files at once. The system gallery app will never show these dialogs. We hope that this improvement makes the user experience more streamlined.

Storage Access Framework changes

After we limited access to broad storage, several app developers attempted to use the Storage Access framework to traverse the entire file system. However, SAF isn’t a suitable tool to support broad access to shared storage. We therefore updated it to limit visibility to certain paths.

In Android 11, users will not be able to grant directory access to the root Downloads directory, the root directory of each reliable SD card volume, or external app directories. Apps can still use the Storage Access Framework API and the document picker to ask the user to select individual files from shared storage.

Special permission for file manager apps

For apps that require broad access to shared storage, such as file managers or backup apps, Android 11 will introduce a special permission called MANAGE_EXTERNAL_STORAGE . This will grant read and write access to all shared storage, including non-media files. However, the contents of app-specific directories, both within internal and external storage, will not be accessible.

We want to continue allowing some apps to have broad access to files on external storage, provided they have a use case that truly requires it. In Android 11, these apps can declare MANAGE_EXTERNAL_STORAGE which will allow them to request the user to grant them “All Files Access” in settings. The following are a couple of app examples that will be allowed:

File managers— apps whose main purpose is to let the user manage files

Backup and restore — apps that require bulk access to files (e.g. switching devices or backing up to the cloud)

However, if your app requires access to a single file, such as a word processor app, you should instead use the Storage Access Framework. You can check out the Google Play policy regarding this permission here.

On Android 11, if your app requires MANAGE_EXTERNAL_STORAGE or uses APIs that rely on file paths, you can support backwards compatibility on older versions by declaring requestLegacyExternalStorage=true in your Android manifest.

You can read more about this in the developer documentation and our talk from the Android Dev Summit 2019.

We value your feedback! You can report issues or feature requests through the issues tracker. Stay tuned for upcoming articles about how to use Scoped Storage with the MediaStore and Storage Access Framework APIs.