Hi all,
I wrote a Xamarin Monogame app which I currently test on my iPad. I have noticed that my app loses its app data after each restart (whether forced or by staying in background for a long time). I followed the tutorials, I tried saving to the Documents/ and Library/ folders but no luck. Any suggestions?
private string _historyFilePath = Path.Combine(MariasekMonoGame.ConfigPath, "Mariasek.history");
//...
public static string ConfigPath
{
get
{
#if __IOS__
var personalPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
return Path.Combine(personalPath, "..", "Library");
#else
return Environment.GetFolderPath(Environment.SpecialFolder.Personal);
#endif
}
}
//...
public void SaveHistory()
{
var xml = new XmlSerializer(typeof(List<HistoryData>));
try
{
using (var fs = File.Open(_historyFilePath, FileMode.Create))
{
xml.Serialize(fs, Game.Money);
}
}
catch(Exception e)
{
System.Diagnostics.Debug.WriteLine(string.Format("Cannot save history\n{0}", e.Message));
}
}