About Target SDK 30, Storage Permissions, and requestLegacyExternalStorage

  • It notifies those apps which set requestLegacyExternalStorage=true, but it didn’t verify those apps go against Scoped Storage.
  • After May 5th, for the app with targetSDKVersion of API 30, it must be modified to use Storage Access Framework or Media Store API, declare why they need MANAGE_EXTERNAL_STORAGE, or remove MANAGE_EXTERNAL_STORAGE.
  1. for those features of creating files or getting images … etc, we refer https://developer.android.com/guide/topics/data and change using Storage Access Framework or Media Store API.
  2. Keep requestLegacyExternalStorage=true. Though it will be ignored for those apps with targetSDKVersion of API 30 running on devices of Android 11, this flag guarantees our apps work as previously behaviors under Android 10.
    https://developer.android.com/about/versions/11/privacy/storage#maintain-compatibility-android-10
  3. Except for file managers, etc, other apps shouldn’t include MANAGE_EXTERNAL_STORAGE, so remove it.
  4. The WRITE_EXTERNAL_STORAGE is also ignored on Android 11, and we prefer keeping requestLegacyExternalStorage=true, so we modify our permission declaration to
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29"
tools:ignore="ScopedStorage"
/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
  1. runs Android 9 or lower,
  2. temporarily opted out of scoped storage (this means <application android:requestLegacyExternalStorage="true" ... >

--

--

--

Lead Android & iOS Mobile Engineer at Yahoo (Verizon Media) Taiwan https://www.linkedin.com/in/hanruyeh/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What to expect when you’re expecting… to publish your 1st Android app

Beagle — A smart and reliable companion library for debugging your Android apps

Kotlin Extension Property

Flutter — How to Show Border Around Image Akshar Mangukiya

How to make an activity full screen in android studio?

Temperature Converter App: Android Kotlin App

PageObject Pattern via Kotlin into Android UI tests

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bram Yeh

Bram Yeh

Lead Android & iOS Mobile Engineer at Yahoo (Verizon Media) Taiwan https://www.linkedin.com/in/hanruyeh/

More from Medium

Development of Android Apps: Goods and Bads

Let’s do ChromeCast Videos with Android. — Part 2

Be Passionate to Publish Android Libs

How to build in-app chat using Kotlin — Part 1