Unity Sqlite Setup


1. Find two files " Mono.Data.SqliteClient.dll" and " System.Data.dll" in local unity directory and put them in the project Assets folder. (two files can also be downloaded from: http://vdisk.weibo.com/s/abG7k )

2. create Test.cs and bind it to camera. After running, "danny.db" is in root directory of the project.

using UnityEngine;

using System.Collections;
public class Test : MonoBehaviour
{
void Start ()
{
DbAccess db = new DbAccess("data source=danny.db");
db.CreateTable("dick",new string[]{"name","height","email","blog"}, new string[]{"text","text","text","text"});
db.InsertInto("dick", new string[]{ "'danny'","'183'","'[email protected]'","'www.danny.com'"   });
                db.CloseSqlConnection();
}

}


3. (optional) download " Navicat Premium", use it to see content of db file.

猜你喜欢

转载自blog.csdn.net/kong5461/article/details/22775293