How to access persistent data path in Android phone?

I am working on porting my Unity windows application to Android and have been trying to figure out how to re-implement the external config-file reading process on a Samsung Galaxy Tab.

I have read that Unity has the Application.persistentDataPath function that returns a safe path for the Android application to perform file IO. On the Galaxy Tab, it returns “data/data/com.MyDemo/files”. I have been trying to copy a simple text config file from windows to that persistent data path on the Android device directly via USB but no matter what I do, I simply could not find the directory anywhere, either in both windows explorer or on the device file manager itself.

This is really baffling to me. How on earth can I “install” basic config files if I cannot even access the data folder manually? Is there anyway to do this?

Does anyone even visit this website? It seems to pale in comparison with StackOverflow...

It does. It's a combination of two things: A: StackOverflow is more general, so it attracts a far larger audience, and B: Unity takes almost no technical knowledge to get started with, but pretty much a full-fledged university-level programmer to master. So, as a result, the Q&A website gets a really tilted ratio of beginners to experts. Sorry I can't be of actual assistance with your question, I guess I just... needed to vent that. >_<

Any answers?

Find a good software to open/show the Android folders in your Windows. I'm trying some software for this, and find the Android Commander as a good option. Link: http://android-commander.en.uptodown.com/

3 Answers

3

Application.persistentDataPath have two paths base on your Write Access setting, you can find it at Build Setting > Player Setting > Other Settings, by default, it is internal Only. means that the path should be point to /data/data/com.your.appid/files which is for development only, user cannot find this files without root android device.

if you set the Write Access as External(SD Card) or add WRITE_ EXTERNAL_STORAGE permission into AndroidManifest.xml, Application.persistentDataPath will point to Android/file/com.your.appid/files of your sd card.

This answer also is correct but goes into a little more detail than the selected answer. Thanks Calvin.

You need to change the build settings for android. change configuration > write access to external (sd card).

Is there any option to make the files accessible within internal storage rather than external sd card?? @Calvin2274

Hope this could help you. https://stackoverflow.com/questions/42630590/how-to-access-file-in-android-internal-storage-for-unity-app