Skip to content
Shrey Malhotra edited this page Mar 21, 2015 · 6 revisions

Welcome to the SqliteForUnity wiki!

Usage is similar to sqlite-net & SQLite4Unity3D. Reiterating it here -

using UnityEngine;
using System.Collections;
using SqliteForUnity3D;

public class PStudent {
    [PrimaryKey]
    public string Id { get;set; }
    public string Name { get;set; }
}

//Creating Tables & Inserting
var factory = new ConnectionFactory();
.....
_connection = factory.Create(dbPath);
_connection.CreateTable<PStudent> ();
_connection.Insert(new PStudent{
    Id = "XYZ",
    Name = "John"
});

//This uses Linq Reflections , please avoid using on iOS
_connection.Table<PStudent> ().Where (x => x.Name == "John").FirstOrDefault ();
//Instead
string name = "John";
_connection.Query<PStudent>(string.Format("select * from PStudent where Name = {0}",name));

Encryption

//To lock db
_connection.SetDbKey(key);
// To unlock db
_connection.Key(key);
Clone this wiki locally