As an Android developer targeting Android 12, can you do anything to allow file browser apps on the phone to view the files that your app exports? Google now requires that all apps use "Scoped Storage", which seems to effectively hide the files from file browsers on the phone. So, you can only view them if you plug the phone into a Windows PC and use File Explorer now.
Asked
Active
Viewed 610 times
-8
-
3Did you read this question? https://stackoverflow.com/q/62782648/792066 and this page https://source.android.com/devices/storage/scoped – Braiam Feb 28 '22 at 12:00
-
Thanks, yes had a look at those but neither seemed to give a clear answer. Looks like a bit of a mess that Google have made. I have about 10 Android apps on Google Play and I changed them all recently to use scoped storage and have had a lot of complaints about users no longer being able to browse to the files on their phones. – Anthony. Feb 28 '22 at 12:07
-
2This question is being discussed on [meta](https://meta.stackoverflow.com/questions/416279). – cigien Feb 28 '22 at 13:44
2 Answers
0
can you do anything to allow file browser apps on the phone to view the files that your app exports
Not if you use an app specific directory like getExternalFilsDir()
as the hack that i posted earlier to open the Files app does not work anymore now. Google closed the leak. Google wants ../Android/data/... to be private.
A further possibility is to let the user choose a directory for your files using ACTION_OPEN_DOCUMENT_TREE
.
Files will be visible with all file managers.
I know you wait for the best solution an you could find it to be this one..

blackapps
- 8,011
- 2
- 11
- 25
-
-
@Taha Sami, you gave me nearly all your points. I dont know what to say. – blackapps Mar 01 '22 at 23:15
-2
Normally the Files app on an Android 11 device (started by the user) will not show content of ../Android/data directory.
But if your app starts it with the following code:
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
List<StorageVolume> volumes = sm.getStorageVolumes();
String uuid = volumes.get(0).getUuid();
String scheme = "content://com.android.externalstorage.documents/document/" + uuid + "%3AAndroid%2Fdata;
Uri uri = Uri.parse(scheme);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(scheme), "vnd.android.document/root");
startActivity(intent );
then it will do.

blackapps
- 8,011
- 2
- 11
- 25
-
Thanks @blackapps, but that does not work on my LG Nexus running Android 8, or Pixel 6 running Android 12. The problem is that volumes.get(0).getUuid() is null. Even though null, it did bring up a file browser app only on my Android 12 Pixel 3a, and if I browsed in the file browser app, then I could find the Android/data folder for my app, which is interesting. Have you tried the above code on any devices? – Anthony. Mar 01 '22 at 00:15
-
I found one app on Google Play called "X-plore File Manager" that seems to be able to view all the files in Android/data even without the code above. – Anthony. Mar 01 '22 at 00:38
-
It works prrfectly on several Android 11 devices. And i said Android 11. – blackapps Mar 01 '22 at 05:16
-
Ok. Thanks. But Android 12 is the current release so it needs to work for that. I'll keep playing around. – Anthony. Mar 01 '22 at 06:06