5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SQLiteKit を使う

5
Posted at
sample.cs
// Application.persistentDataPath 取得したパス配下にDBファイルを作成する
var dbPath = System.IO.Path.Combine(Application.persistentDataPath, "test.db");
var db = new SQLiteDB();
db.Open(dbPath);

// 暗号化
db.Key("0x414243");

// CREATE TABLE
var qr = new SQLiteQuery(db, @"
CREATE TABLE IF NOT EXISTS test_data (
	id INTEGER PRIMARY KEY AUTOINCREMENT, 
	name TEXT, 
	role TEXT
);");
qr.Step();
qr.Release();
qr = null;

// INSERT
qr = new SQLiteQuery(db, @"
INSERT INTO test_data (
	name,
	role
)
VALUES (
	'taro',
	'programmer'
);");
qr.Step();
qr.Release();
qr = null;

// SELECT
qr = new SQLiteQuery(db, "SELECT * FROM test_data");
while(qr.Step()) {
	Debug.Log (string.Format ("{0}: {1} - {2}", query.GetInteger("id"), query.GetString("name"), query.GetString("role")));
}
qr.Release();
qr = null;

db.Close();
db = null;
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?