Search code examples
androidandroid-api-levels

Create App-Specific folder in External Storage in Android Q


I want to create an app-specific folder in Internal Storage similar to Whatsapp, Telegram, etc. Apps whose target SDK is 29, Environment.getExternalStorageDirectory has been deprecated. Now, Android does allow to create such a folder using legacy flags, but I want to know is there any other way to do so.

I want to create a folder at this path - /storage/emulated/0/MY_APP. MY_APPis name of my folder I want to create


Solution

  • I want to know is there any other way to do so

    No. And, on Android 11+, once your targetSdkVersion reaches 30, you will not be able to use android:requestLegacyExternalStorage="true". Note that this should also affect the apps that you cite, except perhaps those that are pre-loaded by device manufacturers.

    What Google wants is for you to use the Storage Access Framework and let the user decide where on the user's device the user's app (i.e., you) should place the user's content, rather than you deciding for them.