Thanks in advance for reading this question.
I’m having trouble reading/writting xml file on android devices. My game require read/write .xml file to function properly. So far i’ve successfully reading the xml content, but failed to overwrite/save the file. I’ve already set the Player Settings > Write Permission > External. I’ve also copied the .xml file to Android > data > com.myCompany.myTitle > files.
This is some way that i tried to read the .xml file:
- Using Streaming Datapath and www, i could read the xml content from www.text property
- Using Persistent Datapath, i could check the file exist from Application.persistentDataPath + “/DataPlayer.xml”. But,i cannot retreive its content.
- Using Resources.Load (“Resources” folder), i could read the xml content. But it seems pre-compiled so the .xml file cannot be edited (please correct me if i’m wrong).
- Using Public TextAsset and assign the xml through unity editor manually (Without “Resources” folder). Then Resources.Load could get its content just like method no.3
The way i’m reading the .xml file was by using XmlDocument with LoadXml(string content) method. Then, i modify the XmlDocument and finally call Save(string path) method. I used the Persistent Datapath as parameter, but what happened next was the xml file become corrupted (size become 0B). My attempt to overwrite the file has been unsuccessful so far.
Some discussion suggest using Persistent Datapath for deploying to mobile platform, but i can’t seem to get it right. Others suggest doing serialize / deserialize, but i’m not quite understand the concept behind it.
Thank you again for reading all this. I hope someone could enlighten me on this matter.