iPhone files not persistent

Question!

I have an iPhone app I have written in C# using MonoTouch. Everything works fine, but there is something funny going on with the files created by my application (a small sqLite database and a temp file). The files seem to exis while the app is resident in memory, but the moment i re-boot my phone, the files are gone (?) As a result the app keeps forgetting what it's doing so to speak.

As adviced in the monotouch docs, I store my files under the "personal" folder. This works fine both on the emulator and my real phone. But as mentioned, the files vanish into thin air if i re-boot or leave the phone alone for a couple of hours (note: as long as the app is running and has focus, everything is ok. iOS seems to keep apps resident even if you exit to the menu).

This is an example of how I get the path for my temp-file:

var documents = Environment.GetFolderPath (Environment.SpecialFolder.Personal);  
return Path.Combine(documents,"tr_activeTask.dat");

I realize that each iPhone app has it's own "personal" folder, which is backed up by iPhone amoung other things. Have anyone experienced this behavior? I cant figure out the cause. Is it somehow connected to the provisioning profile i use (ad-hoc testing)?



Answers

I just looked at my app, and I have this:

BaseDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "..");
Documents = Path.Combine(BaseDir, "Documents");

This Documents folder is where I store everything.



This video can help you solving your question :)
By: admin