Android Api 29 has big changes regarding files and folders. I have not found a way so far to create a folder in the internal storage that is public visible. Every folder I
Starting from Android 10, you should use SAF, and let user choose the directory using ACTION_OPEN_DOCUMENT_TREE
.
If you need a simple example. You can find it here
Alternatively, you could use requestLegacyExternalStorage = true
in manifest when your app is not newly released. But, this is something that should not be used for future release, as this is a short-term solution provided by Google.
Note: In future releases of Android, user will not be able to pick the whole external file directory and Downloads directory, so unfortunately, keep in mind that we are not going to have access to these as well! For more information you can click here
when I use
File root = context.getExternalFilesDir(null);
The created files can only be seen by my app
They can be seen by any app that uses the Storage Access Framework (e.g., ACTION_OPEN_DOCUMENT
), if the user chooses the document that you place in that directory.
I write an app that creates data files that shall be picked up by other apps
Other apps have no access to external or removable storage on Android 10, except in the limited directories like getExternalFilesDir()
or via non-filesystem means (ACTION_OPEN_DOCUMENT
, MediaStore
).
How can I create a folder and files in Android 10 that are public?
Use getExternalFilesDir()
and related methods on Context
. Or, use ACTION_CREATE_DOCUMENT
or ACTION_OPEN_DOCUMENT_TREE
and use the Storage Access Framework. In either case, the resulting documents can be used by other apps that also use the Storage Access Framework.