Android 11 Developer Preview

Most apps published on Google Play request (READ_EXTERNAL_STORAGE) storage permission to do general things like store files on an SD card or read multimedia files. These applications may store a large number of files on disk that will persist even after the application is uninstalled. In addition, these applications may also read sensitive file data from other applications.

In Android 10, we tweaked the way storage permissions work to give apps only the access they need. This also encourages applications to store files in designated directories to limit file clutter. These directories will also be deleted after the application is uninstalled.

The storage changes that Android 10 brings follow three basic principles

  • Better dependency: The system knows which files belong to which applications, which makes it easier for users to manage their files. After an application is uninstalled, files created before the application are not saved on the device unless required by the user.
  • Protecting application data: When an application writes its owning files to external storage, these files should not be accessed by other applications.
  • Protect user data: When users download files, such as email attachments with sensitive information, these files should not be visible to other applications.

Target SDK Level Android 10 apps can use their own external Storage directories and manage media collections (audio, video, images, and download data) without requesting Storage permission. Storage permission allows users to read audio, video, and image collections shared by other applications, but does not allow users to access downloaded data that is not created by the application. In Android 10, the only way to Access non-media files created by other apps is to use the document selector provided by the Storage Access Framework. In Android 11, we will continue to optimize the developer experience for Scoped Storage by following several points.

  • Android 10 external storage permission behavior

Developer. The android. Google. Cn/training/da…

Improved media storage

Android 10 requires all apps to use the MediaStore API to access photos, videos, and music files, and we will continue to do so. But we also know that many deeply dependent applications and third-party libraries based on raw File path apis are difficult to switch to using File descriptors. So in Android 11, apis and libraries that rely on the original file path can be used again. You need to add requestLegacyExternalStorage attribute in the Manifest file applications, in order to make sure the Android users can also use this feature.

In the real world, I/O requests that rely on the original file path are redirected to use the MediaStore API, which can have a performance impact when accessing files outside of the application’s storage space in this way. Using the raw file path directly does not offer any more advantages than using the MediaStore API, so we strongly recommend using the MediaStore API directly.

In Android 10, an application must be approved by the user for each file it requests to edit or delete. In Android 11, apps can request to modify or delete multiple media files at once. The system’s default Gallery application will no longer display these dialogs. We hope this improvement will make the user experience smoother.

Updates to the Storage Access Framework

When we restricted extensive Storage Access, some developers tried to traverse the entire file system using the Storage Access Framework (SAF). However, SAF is not suitable for widespread access to shared storage content. Therefore, we have updated it to limit its visibility to certain paths.

In Android 11, users will no longer be allowed to authorize access to the Downloads root, the root of each available SD card, or the directories of other applications. Applications can still use Storage Access Framework apis or file pickers to help users select individual files from shared Storage.

Special permissions for file management applications

For file managers and some backup applications, they need wider access to shared storage. Android 11 will introduce a special permission called MANAGE_EXTERNAL_STORAGE that grants access to all shared storage, including non-media files. However, an application with this permission cannot access other applications’ app-specific directories, either external or internal.

We want to continue to allow applications that do have extensive access to external storage files. On Android 11, an application with MANAGE_EXTERNAL_STORAGE permission can direct the user to the system Settings page and let the user choose whether to allow the application “All Files Access.” There are two examples where this permission can be used:

  • File manager – the main function of this application is to manage files;
  • Backup and recovery – This type of application requires access to a large number of files (such as migrating data while switching devices, or backing up data to the cloud).

If your application needs to Access a single file, such as a word processing application, you should use the Storage Access Framework (SAF).

Before this policy update is officially launched on Google Play, we would like to ask you about your specific needs in this area. Please click here to fill out the questionnaire and give us feedback.

If your application requires MANAGE_EXTERNAL_STORAGE permissions or API calls to depend on the original file path, then you must be added in the AndroidManifest file requestLegacyExternalStorage = true, This will enable your app to run properly on Android 10 devices.

For more information, check out our shared video from last year’s Android Developer Summit, Get Ready for partitioned storage:

  • Tencent Video Link

V.qq.com/x/page/d302…

  • Bilibili video link

www.bilibili.com/video/av771…

Or check out the Android developer documentation here: Storage Updates in Android 11

We value your feedback and you can send us issues or new feature requests via Issues Tracker. Also stay tuned for future articles on MediaStore and Storage Access Framework APIS to invoke partitioned Storage.