- Home /
When to use persistentDataPath versus dataPath
Hello. I'm working on a game that will be both PC/Mac/iPhone. I need to store data for these locally for players (game state), and was looking at the best way to do this cross platform.
I see that there is both a dataPath and a persistentDataPath. dataPath is fairly well documented, persistentDataPath (which eludes to being the place to store data between runs) doesn't give quite as much context as to when it's appropriate to be used versus dataPath.
has anyone used the two and can they tell me which one they'd use to store the game state data? I did a search here and found three questions related to persistentDataPath, but none of the three were answered. Is peristentDataPath useful, or do people use dataPath and amend it as needed based on the underlying OS.
Thanks.
Answer by OnlineCop · Apr 24, 2012 at 12:38 AM
Late reply, but Application.dataPath
will give you a read-only directory where the entire project can be found. If you have a sibling folder to your Assets/
directory, you can use it like:
Application.dataPath + ".." + Path.DirectorySeperatorChar + "sibling_path"
The Application.persistentDataPath
is different for various platforms (iOS vs Android), and is the /Documents
directory, a read-write path where you can put your downloaded stuff (new assets, for example).
Your answer
Follow this Question
Related Questions
Can't transfer file from datapath to devices 1 Answer
Application.CaptureScreenshot() does not save any image on Android while it does on Editor! 0 Answers
SqliteException: Unable to open the database file - Ready-made DB Provided To Access 0 Answers
Streaming Assets or Persistent Data Path for reading files after build. 1 Answer