Reputation: 11
I'm making my first Windows Phone App
As per this tutorial [ http://msdn.microsoft.com/en-us/library/gg680266(v=pandp.11).aspx ], "To save a serializable object to isolated storage using a dictionary, you just assign the object to IsolatedStorageSettings.ApplicationSettings and specify a key."
In my app, I tried to save a Microsoft.Phone.UserData.Contact object in the dictionary.
appSettings["con"] = myContactObject
And then retrieve it later in another page using
savedContactObject = (Contact)appSettings["con"];
This code works in the emulator and the device as long as the app is open.But when the app is closed, this dictionary pair gets erased. The dictionary is working perfectly for strings and custom objects. It only gets erased when a Microsoft.Phone.UserData.Contact object is saved and the app is closed.
Please tell me if you have any ideas to solve this problem. Thanks for your help.
Upvotes: 0
Views: 661
Reputation: 246
Microsoft.Phone.UserData.Contact objects are not serializable, so application setting will silently ignore those objects. You have to write a custom logic to serialize those objects. Create a MyContact class, transfer all information you want to store there, and save these MyContact objects.
Upvotes: 2