Windows Phone Mango database support: actually pretty good
Join the DZone community and get the full member experience.
Join For FreeBack in June, WindowsPhoneGeek wrote a popular post walking Windows 7.1 developers through creating a simple Local Database application (for storing strings).
A few months later, on September 23rd, Microsoft published their own step-by-step HowTo
(for a to-do list). (The rest of Microsoft's Local Database documentation is probably worth reading/bookmarking too.)
WindowsPhoneGeek's guide is a little easier to follow, because it doesn't explain each step very much. Microsoft's guide explains its code at a fairly low level, so it demands a bit of concentration (like a lot of MSDN documentation).
Now Mark Arteaga has written his own Mango database HowTo, falling somewhere in between those two: clear and a little chatty, and emphasizing the Mango-specific aspects of the code (with spotlighting 'here's something to notice!' comments sprinkled throughout).
Here's how Mark puts his guide in the context of other documentation:
Couple things to cover:
- Connection strings: to get all the details on Connection String and Local Database on Windows Phone see MSDN. But one key thing to notice is isostore which is unique to Windows Phone
- isostore: this essentially means your database was created in code, is read/write and located in isolated storage for your app
- appdata: this essentially means your database was included in your application, is in the installation folder and is read only. You can copy this file into Isolated Storage to make it read/write.
- Initialize – we call this so we can check to see if the database exists and if it does not create it.
- Updating Database – I don’t go through this as it’s another post on it’s own. Read this on MSDN on updating a local database on Windows Phone, it’s a must read!
This is a solid introduction to Windows Phone 7.5's database support. Check it out here.
Opinions expressed by DZone contributors are their own.
Comments