Android 11 - creating app's directory as a shared folder under Storage root

Viewed 429

We need to create our app's directory as a shared one under Internal storage root so that all files/images received and downloaded through our app can be viewed using any File manager, Photo gallery etc. Till Android 10, we were able to do that but in Android 11, when we use getExternalFilesDir to know the root and create app's base directory, it is not visible from a File Manager.

//This is not visible from File Manager
File rootAppDir = context.getExternalFilesDir(null);

//This points to some other location, cannot see base directory of other apps under this
File rootStorageDir = Environment.getStorageDirectory();

We see many other apps that have created their folders under Internal Storage, such as Signal, Telegram etc. Please let us know what we might be doing wrong and how to create our app's base directory under Internal Storage root. Appreciate your help.

1 Answers

We did as recommended by @CommonsWare - set android:requestLegacyExternalStorage="true" in Manifest and (important) marked down targetSdkVersion from 30 to 29. That worked.

Related