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.
- 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
- The next thing to do is to create yourself a Universal project
- 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).
- Next, add a nuget reference to sqlite-net (use the package with that id)
- 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
- 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