Best location to save game data

Hey everyone,

Sorry if this has already been asked, but I haven’t been able to find something which directly addresses my situation.

So I’m trying to determine the best directory/file location to save my applications game data in a platform independent manner. It consists of an xml file which contains all of the general information for items/units/conversations/etc. which get deserialized into the application on an as-needed basis.

I’m familiar with Application.dataPath, but I see that there are certain cases, such as with Android, where the path points directly to the apk. I’ll admit that I’m not too familiar with Android folder and file structures so I’m not sure if this would cause problems if I were to just save the file using a path like this:

string filepath = Application.dataPath + "/gameData.xml";

Any tips on this?

Link to Documentation: Unity - Scripting API: Application.dataPath.

Application.persistentDataPath is a pretty good place.

I personally just save it in a local sub directory of the game called ‘saves’. The reason is if your game has a large save file, with multiple saves per machine, then I definitely don’t want to save it to my small OS hard drive, I want it to be with the game data in the secondary hard drive.