Sqlite for Universal Windows and Windows Phone applications

Sqlite for Universal Windows and Windows Phone applications

I hadn’t tested using Sqlite with the new universal projects introduced with Visual Studio 2013 Update 2 (which includes the Windows Phone 8.1 SDK). Luckily there is already quite a bit of info out there on the bits you need to get this to work.

  1. Firstly, you need a copy of the Sqlite Extensions library updated for WP8.1. At this point this hasn’t been officially release but Tim Heuer has posted a link to his “works on my computer” version of the library. His post is Using SQL/library references in Universal Windows Apps and includes a link to the extensions library
  2. The next thing to do is to create yourself a Universal project
  3. Add a reference to the sqlite extensions library to each of the head projects (ie the Windows and Windows Phone projects, not the shared project).
  4. Next, add a nuget reference to sqlite-net (use the package with that id)
  5. In the previous step you’d see sqlite.cs and sqliteasync.cs being added to both head projects. You can copy these files into the shared project and delete them from both head projects
  6. Lastly, add some sqlite code to your shared project which can then be used by both your Windows and Windows Phone projects…. simply done!

Here’s a sample project where I followed these steps

Leave a Reply

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