1. Make Connection.
- private IDbConnection dbcon;
- ...
- public void OpenDB(string p)
- {
- connection = "URI=file:" + Application.persistentDataPath + "/" + p; // we set the connection to our database
- //connection = "URI=file:" + p; // like this will NOT work on android
- dbcon = new SqliteConnection(connection);
- }
2. load an already populated db in android dev.
- // check if file exists in Application.persistentDataPath
- if(!File.Exists(filepath))
- {
- // if it doesn't ->
- // open StreamingAssets directory and load the db ->
- WWW loadDB = new WWW("jar:file://" + Application.dataPath + "!/assets/" + p); // this is the path to your StreamingAssets in android
- while(!loadDB.isDone) {} // CAREFUL here, for safety reasons you shouldn't let this while loop unattended, place a timer and error check
- // then save to Application.persistentDataPath
- }
- //open db connection
- connection = "URI=file:" + filepath;
- dbcon = new SqliteConnection(connection);
in unity3d 5, there is a problem with sqlite3.dll ( it is 32bit version )