Hi everyone I am new to Unity3D. I have some tables in a SQLite database which I want to use for the game. I am building the game for Android. The game is working in the editor but the Android build is showing me this error:
SqliteException: Unable to open the database file
unable to open database file
at Mono.Data.Sqlite.SQLite3.Open (System.String.strFilename, SQLiteOpenFlags Enum flags, Int32
maxPoolSize, Boolean usePool) [0x00000] in <filename unknown>:0
at Mono.Data.Sqlite.SQLiteConnection.Open() [0x00000] in <filename unknown>:0
this is the code(C#) I have written.I am using Unity 5.6.3p2 and the build in Android6.0
string conn = "URI=file:" + Application.dataPath + "/StreamingAssets/ImageMatchingv1.db"; //Path to database.
try{
IDbConnection dbconn;
dbconn = (IDbConnection) new SqliteConnection(conn);
dbconn.Open(); //Open connection to the database.
IDbCommand dbcmd = dbconn.CreateCommand();
string sqlQuery = "SELECT a.ImageFile ,b.ImageFile FROM ImageMap join Image a on a.Id = ImageMap.LeftImage join Image b on b.id = ImageMap.RightImage WHERE ImageMap.Id IN (SELECT Id FROM ImageMap ORDER BY RANDOM() LIMIT "+ numOptionTile[level] +");";
dbcmd.CommandText = sqlQuery;
IDataReader reader = dbcmd.ExecuteReader();
int i = 0;
while (reader.Read())
{
if (!reader.IsDBNull (0)){
String leftImage = reader.GetString(0), rightImage = reader.GetString(1);
leftImageList.Add( leftImage);
rightImageList.Add(rightImage);
Debug.Log (leftImageList*);*
_ Debug.Log (rightImageList*);_
_ i++;_
_ }_
_ reader.Close();_
_ reader = null;_
_ dbcmd.Dispose();_
_ dbcmd = null;_
_ dbconn.Close();_
_ dbconn = null;_
_ }_
_ catch (Exception e){_
_ scoreText = GameObject.Find (“Score”).GetComponent();_
_ scoreText.text = e.ToString();_
_ }*_
* }*