Add SQLite In Windows Phone Project

Today we are going to look how one can add SQLite in Windows Phone project. All you need is VS 2012 or higher and a computer having a microprocessor that supports SLAT (Secondary Level Address Translation).

1. Create an application in Visual Studio

page

2. To integrate SQLite you are required to add SQLite for Windows Phone. For this go to Tools, Extensions and Updates and search for SQLite or SQLite for Windows Phone.

SQLite windows phone

In my application it is already installed, you will get an Install option, just install it and pass this step.

3. In the last step you just installed SQLite. Add this in your project, right click Reference, then Add Reference.

Addreferences

Now go to Windows Phone 8.1, then Extension, mark and click Ok. And you will see this in your reference section.

Extension

If you did it in the same way that means you successfully added SQLite in your project. But what happens with a yellow triangle, it is due to the processor architecture. In this case all you need is to change the processor configuration.

4. Click Solution, Configuration Manager and change the Platform from Any CPU to ARM.

Configuration Manager

Just Rebuild the project and problem goes away.

5. Now you need to add Sqlite-net, right click on Add references and select Manage Nuget Packages and search for sqlite-net. Wait for the result and then Install it.

add Sqlite-net

This will add these two classes in your project. Now you are good to go with your server less database.

cs code

Note: In any case you get errors like the image shown below do the steps that are mentioned and you are done.

Error

Error

Double click on the error and it will lead you Sqlite.cs.

Sqlite

It is because you need to add USE_WP8_NATIVE_SQLITE in Conditional Compilation Symbols. To do that right click on your Windows Phone project and then click Properties.

USE_WP8_NATIVE_SQLITE

The last step is to build your project. If you have done everything fine you will get success.

Next we will look at CRUD operations. Stay tuned and Happy coding!

Up Next
    Ebook Download
    View all
    css
    Read by 0 people
    Download Now!
    Learn
    View all