Using the SQLite database
Installing the SQLite for Windows Phone 8.1 plugin
New Windows Phone 8.1 project
Add SQLite for Windows Phone 8.1 reference
Because the component relies on Microsoft Visual C + + for Windows Phone, it also references the Microsoft Visual C + + runtime package for Windows Phone
Right-click to manage Nuget package references
Search for sqlite-net and install
1 Public class Person2 {3 [PrimaryKey, AutoIncrement]4 Public intId {Get;Set; }5[MaxLength (8)]6 Public stringName {Get;Set; }7 Public intAge {Get;Set; }8 Public CharGender {Get;Set; }9}
Person
1 Private voidButton_Click (Objectsender, RoutedEventArgs e)2 {3 //CREATE DATABASE (no presence created, open if present)4 varConnection =NewSqliteconnection ("temp.db");5 //Create a table6Connection. Createtable<person>();7Person Zhang =NewPerson ();8 //Zhang. Id = 1;9Zhang. Name ="Letter Zhang";TenZhang. Age = -; OneZhang. Gender ='male'; A //Add Data - varresult = connection. Insert (Zhang);//returns the number of rows affected by the execution result - System.Diagnostics.Debug.WriteLine (result); the //Update Action -result = connection. Update (Newperson {Id =2, Name ="Zhangsan", age = + }); - System.Diagnostics.Debug.WriteLine (result); - //reading Data + vartemp = connection. Find<person> (1); - System.Diagnostics.Debug.WriteLine (temp. Name); + //Read all data A varList = connection. Query<person> ("SELECT * from person where id>=?",1); at foreach(varIteminchlist) - { - System.Diagnostics.Debug.WriteLine (item. Name); - } - //Delete Operation -Connection. Delete<person> (1); in}
Windows Phone Nine, SQLite database