SQLite Database in Windows phone app – Part 1 (Installation and Setup)

While developing applications there may be a need to store data and access it for later use. Windows Phone provides us with different ways to store our application data depending on the size. But when dealing with large data involving multiple entries, database is the appropriate method.


Windows phone 8.1 Runtime app supports SQLite database. So in this article I will explain you how to install and setup SQLite database reference in your windows phone application.

Follow the steps given below


Step 1:
Create a new Project having the name SQLiteDatabase.



Step 2:
Install the SQLite for Windows phone 8.1 SDK

Go to Tools->Extensions and Updates



Then type the keyword sqlite in search bar in the online tab. And install the SDK SQLite for Windows Phone 8.1



Note: If you don’t find the required library in Visual Studio gallery you can download it from the required web page.


Step 3:
Add the SQLite Reference to your Project



Go to References->Windows Phone 8.1->Extensions



When done, you will see that the proper references to SQLite and Visual C++ 2013 Runtime have been added to your project



Step 4:
Change the target Platform of your Project

You may have already noticed, that the references show a warning symbols, to resolve that the next thing to do, before compiling the solution is changing the architecture of the target platform. This is the fact that the engine of Sqlite is written in C ++, and the default target platform set in the project is Any CPU. This mode is not supported.

So in order to resolve this go to Configuration Manager as shown in the figure below



In the next dialog, we note that we have several choices of platforms, Any CPU (the default), ARM, x64 and x86.

Now we change the target platform accordingly. If you want to debug your app on Phone then choose the ARM Platform. But if you wish to debug your app on Emulator or Windows PC select x86 or x64 configuration depending on your processor if it is 32 bits or 64 bits.



Note: Every time you change your debugging option from emulator to phone you need to change the debug configuration accordingly.


Step 5:
Installing sqlite-net package

After installing the library for SQLite, we need sqlite-net NuGet package. With this library, we will be able to perform all the operations that you normally do in a database, such as Insert, Delete, Update and run search queries. This package provides two helper classes (SQLite.cs and SQLiteAsync.cs).

To install it right click on the project->Manage NuGet Packages and search for sqlite-net



Finally we have completed the SQLite setup. In the next blog post I will be explaining you how to perform different operations like insertion, deletion and searching in SQLite database.



Chetan Gulati

Currently am doing B TECH in IT from Delhi Technological University. App development is my passion. Believe in quality rather than quantity.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding