Notes on using third-party SDKs to share files with other apps on Android 11

Privacy and security are the core of our design of Android. With each new version released, we will increase our investment in this area. Android 11 also continues to make important progress in these areas.

Android 11 (API level 30) further enhances platform functions, providing better protection for applications and user data in external storage. Starting from Android 11, even apps that use partitioned storage have the READ_EXTERNAL_STORAGE permission, they can no longer access files in the exclusive directories of any other apps in external storage.

  • Partition storage mode

    https://developer.android.google.cn/training/data-storage#scoped-storage

  • Exclusive catalog

    https://developer.android.google.cn/training/data-storage/app-specific#external

Affected by this limitation, if your application shares files (such as sharing photos with friends on another application) to other applications through a third-party SDK, this is just to pass the file path in its own dedicated directory to the target application. The application will not be able to read the file. Part of the sharing SDK may not handle this situation correctly, without an explicit error report but just silent failure (the other user is not aware of this sharing), which affects the developer and user experience.

If your application needs to share files with other applications on Android 11, please check whether the third-party sharing SDK you are using supports sharing through FileProvider (most commonly used third-party sharing SDKs now support it). With FileProvider, your application can allow third-party applications to read the shared files without being restricted by partition storage.

  • Please refer to the developer documentation of FileProvider and related sample code

    https://developer.android.google.cn/reference/kotlin/androidx/core/content/FileProvider

  • For more information, please refer to our developer documentation on Android 11

    https://developer.android.google.cn/about/versions/11/privacy/storage


Recommended reading




 Click the screen at the end read read the original article  | instant access to Android 11 official documents  


Guess you like

Origin blog.csdn.net/jILRvRTrc/article/details/108988668