I am developing a .APK in Unity, where I have a BD in SQLite
.
When doing tests within the Unity environment everything works perfectly, but when exporting it to .APK
and testing it on my phone, after executing 2 queries in a row the program "crashes" I put it in quotation marks since the interface keep responding.
SQLite code of the query;
public bool UsuarioCorrecto(string nombre, string contra)
{
int code = 0;
using (SqliteConnection con = new SqliteConnection(connection))
{
con.Open();
using (SqliteCommand cmd = new SqliteCommand())
{
cmd.CommandText = @"select nombre from Usuarios where nombre like @nombre and contrasena like @contrasena";
cmd.Connection = con;
cmd.Parameters.Add(new SqliteParameter("@nombre", nombre));
cmd.Parameters.Add(new SqliteParameter("@contrasena", contra));
using (SqliteDataReader reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
code = 1;
}
else { code = 0; }
}
}
}
if (code == 1)
{
return true;
}
else
{
return false;
}
}
Code to authenticate a user;
public void deleteUltimaCon()
{
using (SqliteConnection con = new SqliteConnection(connection))
{
con.Open();
using (SqliteCommand cmd = new SqliteCommand())
{
cmd.CommandText = @"delete from ultimaCon";
cmd.Connection = con;
cmd.ExecuteNonQuery();
}
}
}
public void Conectar_Click()
{
if (conectarDB())
{
#if UNITY_ANDROID
dialog.showDialog("Usuario correcto!");
#endif
db.deleteUltimaCon();
db.anadirUltCon(nombre.text);
MensajeConectar.text = "Exito..";
ProjectVars.Instance.StringActiveBetweenScenes = nombre.text;
SceneManager.LoadScene("menJugador");
}
else
{
mostrarTextAut();
MensajeConectar.text = "Fallo de autentificación";
Invoke("ocultarTextAut", 1.5f);
}
}
Testing with messages the execution stays on the line where it says db.deleteUltimaCon();
How could I fix it so that the application does not get "hung up"?