- Home /
How to create a SQLite database in Android
I am trying to create a simple database in my application. It works normally on pc, but, when I create the apk and install it, the game doesn't create the database. Follows below the code I am using.
void Start () {
if (Application.platform == RuntimePlatform.Android) {
path += Application.persistentDataPath + "/"; // path starts with "URI=file:"
} else if (Application.platform == RuntimePlatform.IPhonePlayer) {
path += Application.dataPath.Replace("/Data","") + "/";
}
Screen.sleepTimeout = SleepTimeout.NeverSleep;
Screen.orientation = ScreenOrientation.Portrait;
Auxdb.OpenDB (path + dbName);
ArrayList columnNames = new ArrayList() ;
columnNames.Add("Date");
columnNames.Add ("Points");
ArrayList columnValues = new ArrayList() ;
columnValues.Add ("text");
columnValues.Add ("text");
try{
Auxdb.CreateTable (tableDB, columnNames, columnValues);
}catch{
}
Auxdb.CloseDB ();
}
Comment