- Home /
Android: Writing persistent data to SD Card
I know that with Android, you can either save things to the internal memory's persistent data path, which is usually stored in the /data partition (which is read-write to apps).
However, when you deploy for Android, the editor allows you to install the application either "External" (SD Card?) or "Internal" (/data partition). I was wondering, does this affect the application's persistent data path, which on PCs are "%AppData%/Local/companyName/title".
In short:
Install internally -> Game persistent data path is internal.
Install externally (SD Card) -> Game persistent data path is external.
Or does Unity have functions for Android that allows me to see where the SD Card path would be? I'm thinking I'll save my player data on the SD Card, so if their device crashes and they lose the apps, their saved data is still intact.
I would also obviously tick the "This game uses SD Card" box in the editor so Android knows I need R/W to the SD Card.
Answer by supernat · Jul 12, 2015 at 05:35 AM
You can see Android's sdcard path using the Application.persistentDataPath. Using that, you'll have to use File I/O to save/load data yourself. It would be nice if they added an option to store/load PlayerPrefs in a user-defined directory someday. Be sure your File I/O code checks for missing files or failure loading/saving, since the SDCard may be removed, full, or different.
Answer by AuriMoogle · Jun 04, 2018 at 09:11 PM
It's not sure that you will get the path to the sd card with the persistent path case the app could be saved on the emulated external storage, which is on the internal storage!
You can get the path to the sd card independently of the installation path: stackOverflow-HowToAccesSDCard
Your answer
![](https://koobas.hobune.stream/wayback/20220611230909im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Storing mobile data - limits on mobile 1 Answer
Load text file on Streaming assets in Android 4 Answers
Load function not working propperly? 1 Answer
Access internal Storage 1 Answer
Android File-io? 1 Answer