hi, just wondering what the procedure is for reading/writing to a file using json for an Android build. I have no issues with this in the editor but of course in my build it seems that nothing at all is being read/written. I’ve tried pre-processor directives. here is an example …
svo is a class which is marked as serializable, it just holds some data…
using UnityEngine;
using System.Collections;
[System.Serializable]
public class svo {
public string grade;
public int goldFound,treasureFound;
public bool hasTakenDamage;
public float time;
}
application.persistantDataPath works in editor too but not when I try to run the build on my phone, do I have to use the WWW class to do this? If anyone has any incite it would be much appreciated, thanks!
hey, thanks for the reply. I edited the post, also checked the write permission…it is set to internal, the other option is external(sd card). I have tried both persistantDataPath and streaming assets, both aren’t working with the way I have things set up. I’m thinking this is a simple fix but just not sure how to get it working on android. I’ve had similar issues with android stuff in the past, so annoying, it just slows things right down.
got it working, the issue was the path… use Path.Combine( application.persistentDataPath, yourFileName + “.json”); the extension .json seemed to get it working. Also, I had the logic that wrote the json file in a “save” method that was being called form another class but I did not have the path variable declared within the save method itself, I had it above, in start. I assume start was not being called, only the save method… So I was also getting errors saying that the path was NULL, anyway, its all fixed now