Hello everyone,
I have a big problème on my code because I’m using XML file that I modify on runtime. Everything works great on my computer because I access the file with the path, but on my android phone nothing works. I tried to create a Resources folder but it’s not for me because I need to access the xml file (that is ok) and wrote into it (impossible in Resources folder).
So I’m using a StreamingAssets folder where I put all my xml file, and I access them with :
_fileName = Application.streamingAssetsPath + "/XMLActivity";
Again on my computer everything works but on my phone nothing has change. I don’t know how to check if the content of the StreamingAssets is in my build (the .apk file) and how to fix my problems.
the problem is that I need to access my xml file on my android build to read and write. Here is my code to read and write my file :
public void LoadData()
{
XmlSerializer serializer = new XmlSerializer(typeof(List<OneActivity>));
if (File.Exists(_fileName))
{
FileStream stream = new FileStream(_fileName, FileMode.Open);
_listOneActivity = serializer.Deserialize(stream) as List<OneActivity>;
stream.Close();
}
}
public void SaveData()
{
XmlSerializer serializer = new XmlSerializer(typeof(List<OneActivity>));
FileStream stream = new FileStream(_fileName, FileMode.Create);
serializer.Serialize(stream, _listOneActivity);
stream.Close();
}
There is a lot of people that have the same issue than me as I found but no one answer their post, so I figured I would ask again.
https://answers.unity.com/questions/1271003/android-build-doesnt-work-properly.html
https://answers.unity.com/questions/1669280/create-a-text-file-in-my-android-device.html
Any idea would be welcome, thanks in advance.