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.

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.

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