- Home /
[Android] How to share a directory between two apps?
I'd like to be able to read/write files and directories from a directory where another app reads and writes files and directories.
Apparently, I can only access dataPath, persistentDataPath and StreamingAssetsPath. How do other apps write in other directories?
Answer by Bunny83 · Dec 12, 2017 at 04:57 AM
The directories for dataPath and persistantDataPath are usually protected folders which can only be accessed by the app they belong to. So there's no way another app can access files in those folders. StreamingAssets is not an actual folder. The path returned is actually an URL to a location inside the APK package. This "folder" can only be accessed through the WWW class or a UnityWebRequest.
You should store the files in a public folder where every app has access to. WoozyBytes posted an example over here how to get the default external storage path.
. If you want to access data another app stores in it's private folders you're out of luck. Only with root access you could access those folders.
Answer by molul · Dec 12, 2017 at 07:19 AM
I didn't explain my case correctly. I do want to apps to share a public folder, not their private ones. I'm checking that example. Thanks!
By the way, why do I have to go for the external data path? I'd like to read/write in the internal storage. Ideally I'd like to use a directory in the same path as Download, DCIM ,etc.
Oh my, I just found out that in order to access a folder like Download, I need to set write permission to external. This will let me read and write folders outside the app's private directory. Cool!