One topic I was keen to get deep into early on in this book was the subject of local databases. Every app that you will ever build will need some form of local storage, and if you need to store a decent amount of structured data, a database is the only way to go.
Back in the days of Windows Mobile (the version before Windows Phone), the local database story was actually really good. Because these devices were targeted at enterprises, Microsoft’s approach was to put a cut-down version of SQL Server on the devices and build a synchronization framework that would let an enterprise’s SQL Server push and pull data to the devices.
In Windows Phone, Microsoft got rid of all that, and the new device platform launched with no database support at all. You could write data to the filesystem, but that was about it. This strategy, however, is working fine because Windows Phone is a consumer play and not an enterprise play. Windows 8/Windows RT follows the same approach as Windows Phone—there is no built-in database that we can just use. We’re going to use SQLite, a popular open source database that is used on all of the other mobile platforms.
We’ll use the database in two different ways common to Windows Store apps:
We’re going to create a database table to store system settings. (An example of a setting that we’ll build is the user’s last logon username so that we can persist that between sessions.) This will be a simple name/value store that will store string ...