2

In Android 29, I want to be able to share large files between multiple Android users. Is it possible to make a shared directory that users can access? And can that directory be made browse-able by applications that the users have installed?

Or perhaps have one user with the original directory and files, and other users have a mounted/symlinked directory?

It is important for my implementation that an installed app can access this directory.

I have been navigating the Android filesystem and trying to get my head around: /mnt/user/0, /storage/emulated/0, and /data/media/0/ but I cannot see a way to make a symlink in another user's home directory to a folder within these directories.

Jayae
  • 79
  • 2
  • 5

1 Answers1

2

The directory that you are looking for is actually /storage/emulated/0 in your case. I mean the only directory that could be used/accessible by all other applications is the external storage.

However, from Android Q (targetSDKVersion 29), the external storage permission has quite a few changes.

I would recommend looking into the documentation of getExternalStoragePublicDirectory if you are on an Android version that is less than Android Q.

For Android Q and greater, I would recommend looking into the documentation of getExternalFileDir.

Also, there is a great article from @CommonsWare regarding this. Please have a look here in his blog post. I am quoting from his blog here.

For Android Q, you can add android:requestLegacyExternalStorage="true" to your <application> element in the manifest. This opts you into the legacy storage model, and your existing external storage code will work.

Technically, you only need this once you update your targetSdkVersion to 29. Apps with lower targetSdkVersion values default to opting into legacy storage and would need android:requestLegacyExternalStorage="false" to opt-out.

Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
  • 1
    I think the link to blog is broken? I see from those Android documentation pages that: On devices with multiple users (as described by UserManager), each user has their own isolated shared storage. Applications only have access to the shared storage for the user they're running as. Which is a shame, I wanted it the directory to be accessible by each user. – Jayae Apr 28 '20 at 15:17
  • I have updated the link to the blog post. Please have a look. Thank you! – Reaz Murshed Apr 28 '20 at 15:19