Writing to an xml file doesn't work on android
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.
void OnApplicationQuit() { 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[0].GetComponent<Button>().getPoint();
area1.maxHit = Area1Cubes[0].GetComponent<Button>().getHit();
area1.button1 = Area1Buttons[0].GetComponent<Buying>().getCompleted();
area1.button2 = Area1Buttons[1].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();
}
Answer by RodrigoGomes · Jun 14, 2016 at 05:15 PM
Have you fixed this?? I am hacing the same issue :(
Your answer
![](https://koobas.hobune.stream/wayback/20220612074849im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Cant save file into Android internal memory 1 Answer
Cannot Download files to Android device (v5.3.5f1) 1 Answer
Android Game Save and Load doesn't work 0 Answers
Save Data Android C# 0 Answers