Back to Windows Phone 7 Database

Since Microsoft now released RTM version of their tools for Windows Phone 7 development, I updated my phone database project to the latest version as well.  You can find this project here : http://winphone7db.codeplex.com/.

I added also a new feature – ability to create tables with data on desktop, then load them into the database when application runs for the first time.  In order to optimize the process, I am setting this table content (XML files) as Content in my sample application.  If you set your additional files as resources, they will be immediately loaded into memory, while this is not the same for files marked as content.  Here is a screenshot that illustrates the settings.

image

Next step is to read content in Windows phone 7 application.  Here is how I am doing it:

string

content = string.Empty;
Uri uri = new Uri(“test.xml”, UriKind.Relative);
StreamResourceInfo info = Application.GetResourceStream(uri);
using (StreamReader reader = new StreamReader(info.Stream))
{
    content = reader.ReadToEnd();
}

 

 

Pretty easy, hah?

Please look at downloaded application at http://winphone7db.codeplex.com/. for sample use of my database.

Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *