c# - How to make Sqlite work for Android with Unity and SQLiteUnityKit -
to make unity app android, need use sql, , looks sqlite supported on every platform. despite this, i'm having following issue:
i using sqliteunitykit, , looks lot of people have been using framework building sql app.
here code tried make work doc:
public class databasemanager : monobehaviour { sqlitedatabase sqldb; public text firstname; void awake() { string dbpath = system.io.path.combine (application.persistentdatapath, "game.db"); var dbtemplatepath = system.io.path.combine(application.streamingassetspath, "default.db"); if (!system.io.file.exists(dbpath)) { if (application.platform == runtimeplatform.android) { www reader = new www(dbtemplatepath); while ( !reader.isdone) {} system.io.file.writeallbytes(dbpath, reader.bytes); } else { system.io.file.copy(dbtemplatepath, dbpath, true); } } sqldb = new sqlitedatabase(dbpath); //insert string query = "insert person values('b', 'david')"; sqldb.executenonquery(query); query = "insert person values('b', 'alex')"; sqldb.executenonquery(query); //query var result = sqldb.executequery("select * person"); var row = result.rows[1]; debug.log("lastname=" + (string)row["lastname"]); debug.log("firstname=" + (string)row["firstname"]); firstname.text = (string)row ["firstname"]; } }
the problem code works fine when launch project can see:
but in android emulator:
there never name coming. stays "my lastname" nothing more placeholder.
edit: tested build project mac application , runs without problem.
Comments
Post a Comment