Wednesday, April 14, 2010

Serialization and IsolatedStorage as a data persistency approach for Windows Phone 7

So, We don't have a local db support. What we can do to accomplish a workaround for that ?
First thing I've thought about was Serialization. We can create our objects, Specify them as Serialized and Save them either in binary format (using BinaryFormatter- to store binary data such images) or XML format (using SoapFormatter).
Looking into Windows Phone Application References, you will see that System.Runtime.Serialization is supported. add that and then import into your code class.
  • See that we can't achieve this approach because we don't have:
    1. BinaryFormatter and SoapFormatter
    2. ISerializable interface
Ok, let's try creating POCOS and saving them using IsolatedStorage.
  • add the reference then import System.Runtime.Serialization
  • Define the POCO, like this
    public class MyObject
    public int P1 {get; set;}

    public MyObject2 O1 {get; set;}
  • Remember to define MyObject2 as a POCO again
  • after defining all your POCOS, create a Serializer class and try to Save data using IsolatedStorageFile and IsolatedStorageFileStream).
  • Well, I've created a Test UI and this worked for me, but... again, The Emulator didn't persist the data after reloading it.I'm still not sure what's the reason for that, and seems like WP7 Emulator doesn't have an SD card option like Andriod.
The next thing I'm going to try is the creation of a class library for this code and then trying to incorporate it, Or the use of XML and XML Parsing.


  1. I am truly impressed by the details which you have provided regarding Russia Import Data It is an interesting article for me as well as for others. Thanks for sharing such articles here.

  2. one of the best US import data
    We Are give best quality services in vey low prices