I need to load my json file in my device. It is working perfectly fine in Unity Editor but when I transferred it to my device, json isn't there. Currently using this code for adding data in my json file:
TextAsset file = Resources.Load("Products") as TextAsset;
string jsonString = file.ToString ();
Debug.Log (jsonString);
if (jsonString != null)
{
jsonParser data = JsonUtility.FromJson<jsonParser>(jsonString);
data.products.Add(product);
Debug.Log(data.products[1].code);
jsonString = JsonUtility.ToJson(data);
Debug.Log(jsonString);
}
And this for retrieving:
TextAsset file = Resources.Load("Products") as TextAsset;
string json = file.ToString ();
//string path = Application.streamingAssetsPath + "/Products.json";
string path = Application.persistentDataPath + "/Resources/Products.json";
string jsonString = File.ReadAllText (path);
jsonParser data = JsonUtility.FromJson<jsonParser>(jsonString);
It can be use in Unity editor but not in my android device. What seems to be the problem? Very big thanks