This question as been asked by a bunch of people but none seem to work for me. The first issue usually addressed is if the file in resources. Yes my file is in the resources folder and I can successfully call it using Resources.Load(path). The problem is at the end I want write to the same file I loaded but when ever I push the app to my android phone it does not save to the file, unlike when I test it in unity. The file I’m using is an xml and I have everything in place to work it just won’t save. I am unsure whether it is just using the wrong path or if I need to unzip the .apk in order to write to the file.
I would also like to note I’ve tried using a file that is just inside the memory of the phone but that still did not work. Second note I’ve tried to find a definitive answer on whether I need to unzip the .apk but all the forums I’ve come across, including a couple wiki pages, don’t mention it.
AreaContainer Areas = new AreaContainer();
Area area0 = new Area(); area0.name = "Matter"; area0.character1 = 'R'; area0.amount1 = ScriptBox.GetComponent<Points>().getPoints(); Area area1 = new Area(); area1.name = "1"; area1.point = Area1Cubes.GetComponent<Button>().getPoint(); area1.maxHit = Area1Cubes.GetComponent<Button>().getHit(); area1.button1 = Area1Buttons.GetComponent<Buying>().getCompleted(); area1.button2 = Area1Buttons.GetComponent<Buying>().getCompleted(); Areas.areas.Add(area0); Areas.areas.Add(area1); var serializer = new XmlSerializer(typeof(AreaContainer)); File.SetAttributes(Application.persistentDataPath+ "/Resources/Areas.xml", FileAttributes.Normal); var stream = new FileStream(Application.persistentDataPath+ "/Resources/Areas.xml", FileMode.Create); serializer.Serialize(stream, Areas); stream.Close(); }