Location of Application.persistentDataPath in a build

In the answer below:

  • companyname = Company name from the Build Settings
  • productname = Product name from the Build Settings

enter image description here



Windows Store:



~/Library/Application Support/companyname/productname

older version of Unity on Mac:

  • ~/Library/Caches folder

  • ~/Library/Application Support/unity.companyname.productname.



which is the-same as




with SD card on the Android device:




Example of the RandomFolderName full name:


On iOS, you will be given access to the app’s sandbox which is the Document folder. You must create folder inside this directory in order to create a new file inside it.

If you have a default data values in a json file, put the file in Assets/Resources folder so that it will be read-only then read it with TextAsset. When the game loads, you can use PlayerPrefs to check if this is the first time the game being loaded.

If this is the first time, use the value from TextAsset.text. If it is not use then value saved with the DataHandler class.

Roughly something like this:

if (PlayerPrefs.GetInt("FIRSTTIMEOPENING", 1) == 1)
    Debug.Log("First Time Opening");

    //Set first time opening to false
    PlayerPrefs.SetInt("FIRSTTIMEOPENING", 0);

    //USE TextAsset to load data
    TextAsset txtAsset = (TextAsset)Resources.Load("player", typeof(TextAsset));
    string tileFile = txtAsset.text;
    PlayerInfo pInfo = JsonUtility.FromJson<PlayerInfo>(tileFile);
    Debug.Log("NOT First Time Opening");

    //USE DataHandler to load data
    PlayerInfo pInfo = DataHandler.loadData<PlayerInfo>("player");

Leave a Comment