Local Storage (SQLite) Using Windows 10 UWP Apps

Local Storage (SQLite) Using Windows 10 UWP Apps

The Windows 10 Universal app local storage using SQLite database. Step-by-step implementation.

Step 1:

Create new universal project / library using VS2015 RTM Version

Step 2:

Install “sqlite-uap-3081101.VSIX “from Extensions and Updates
VS 2015 --Tools --Extensions and update --search sqlite-uap -- Click Install -- Restart VS 2015

Step 3:

The next step is to add the SQLite.Net-PCL library to your project

Step 4:

Now, remember the sqlite-uap (Visual Studio extension) installed earlier. It installs SQLite extensions that you need to reference by right-clicking on Project References and choosing "Add Reference..." and then finding the right reference under Windows Universal è Extensions.

Step 5:

Coding:

class LocalDatabase
{
public static void CreateDatabase()
{
var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Contactdb.sqlite");
using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath))
{
conn.CreateTable();
}
}
}
public class Contact
{
public int Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string Mobile { get; set; }
}

0 Comments

Featured Post

Understanding about Azure Region, Geographies, Availability Zones and Region Pairs

Introduction Microsoft Azure services are available in 53 regions around the world, with plans announced for 7 additional regions and 140+ a...

Subscribe to the FREE Weekly Newsletter to receive all the latest Microsoft Azure, AI, Xamarin

Popular Posts