I have read a ton of articles on writing to the internal storage of an android device, and I need some help figuring out what I am doing wrong. In the main activity of my app, I read a value from a file stored in the internal storage like this:
string ID = GetID(); Where GetID looks like this: string GetID() { try { using (var i = new StreamReader (OpenFileInput (FILENAME))) { return i.ReadToEnd(); } } catch { return ""; } } If the file doesn't exist, "" is returned and the user is sent off to another activity to register. In that activity, I use this to call a function to write to internal storage like this: WriteID (uniqueID); Where WriteID looks like this: void WriteID(string uniqueID) { using (var o = new StreamWriter ( OpenFileOutput (FILENAME, FileCreationMode.Private))) o.Write (uniqueID); } This is where it gets weird for me, if I put these two functions in the same activity, write to the file and then call the function to read from it, I get uniqueID returned correctly. However if I stop the app and then restart it, I get a File Not Found exception thrown and nothing returned from the read function. However, if I create a new project, and use the same code, everything works as expected (file is created and written to, then on restart the data persists). So I am thinking there is some setting that I have changed or some reference that I may be missing in my original app that causes the internal storage file to be removed when the app is stopped? Any ideas as to why this works correctly in my test app, but not in the other? -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Internal-Storage-file-not-found-tp5713195.html Sent from the Mono for Android mailing list archive at Nabble.com. _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid