internal void SaveApplicationState() { MobeelizerTombstoningState state = new MobeelizerTombstoningState(); if (application.IsLoggedIn) { state.LoggedIn = true; state.User = application.User; state.Password = application.Password; // TODO: encrypt password state.Instance = application.Instance; state.SyncStatus = application.CheckSyncStatus(); state.SyncTicket = this.syncTicket; } else { state.LoggedIn = false; } using (var iso = IsolatedStorageFile.GetUserStoreForApplication()) { if (!iso.DirectoryExists(DATA_DIRECTORY)) { iso.CreateDirectory(DATA_DIRECTORY); } using (IsolatedStorageFileStream stream = iso.OpenFile(System.IO.Path.Combine(DATA_DIRECTORY, DATA_FILE), System.IO.FileMode.CreateNew)) { XmlSerializer serializer = new XmlSerializer(typeof(MobeelizerTombstoningState)); serializer.Serialize(stream, state); } } Log.i(TAG, "Mobeelizer application state saved"); }