- First, download and install the SQLite VSIX for Windows RT. I don’t think I found this step in any tutorial:
- Change the project’s build platform to x86 (you’ll find it in the top toolbar, where it should originally say “Any CPU“).
3) Now go to
Add Reference->Windows->Extensions->SQLite for Windows Runtime. Your references will then look like this:This on its own only adds support for SQLite, but not any classes or other code elements.
- Open the Nuget Package Manager and search for
sqlite-net: sqlite-netdoesn’t add any reference to your project, but it creates 2 files for you:- Write a class that will correspond to 1 row in the table. Don’t forget to add the
PrimaryKeyattribute to 1 property:C#class Row { [PrimaryKey()] public int ID { get; set; } public string Retezec { get; set; } } - Write code that uses this class. My sample code will give you an idea of how to use SQLite in Windows 8 (then use the debugger and a breakpoint to verify that the row you created in the
ifclause was actually created):
C#string databasePath = Windows.Storage.ApplicationData.Current.LocalFolder.Path + "db.db3"; SQLiteConnection connection = new SQLiteConnection(databasePath); Row row = null; bool insert = false; if (insert) { row = new Row(); row.ID = 1; row.Retezec = "Retezec do DB"; connection.CreateTable<Row>(); connection.Insert(row); } else { row = connection.Get<Row>(1); } </Row></Row>
And that’s all there is to it. I hope this will be useful to someone. One thing I forgot to mention at the start: if you want to try this out, you need Visual Studio Express 2012 for Windows 8 or newer.


