save Contact in isolated storage in windows phone 7 c#
Can I save Contacts in Isolated Storage in Windows phone 7 ? and How can I access it in c# ? and which is the best way to save it using li开发者_高级运维nq to sql or Files or Values ?
No No No, you can NOT save even one Contact Object of type "Microsoft.Phone.UserData.Contact" in the isolated storage. The reason is simple: Contact object is un-serializable. I have tried this by myself and did not work, for sure. Consequently, you can NOT save a list of contacts.
Details:
I tried the following scenario: created a contact object, saved it in the isolated storage, tired read it from the isolated storage while the application is running (still alive). The result: it worked and read all the data I previously filled.
BUT
When I closed the application, I tried to retrieve the contact data (contact object that I previously saved) there application crashes and the debugger told me "KeyNotFoundException" which means that no "contact" were stored at all with the same "key" I used to store the "contact" in the first time.
So, why the application can read the stored "contact" in the first time before closing and reopening that application? It was reading form the isolated storage object in the memory not from the one saved on the phone.
Yes, you can read contact information (see http://msdn.microsoft.com/en-us/library/hh286416(v=vs.92).aspx) and save it to Isolated Storage in the same way you could save anythign else there.
The "best" way to save it will depend on what you wnat to do with it and how you want to access it.
Remember that you'll have to keep your copy of the contact information in sync with the actual data though. Unless you have a REALLY good reason to keep this copy of the data I'd avoid doing this and just query the actual contact data store when you need it.
精彩评论