I have a table in sqlite with an integer field called Tipo
, it happens that according to the type number certain options will be shown to the user, so I made a switch
but it marks the error in the number of case
of switch
:
"Incompatible types, required java.lang.String, found int"
and I do not understand why.
private conexion con;
Context context;
SQLiteDatabase bd;
//inicializar
con=new conexion(context,"bd_SQLITE",null,1);
bd= con.getWritableDatabase();
//metodo para consultar
Cursor c = bd.rawQuery("SELECT * FROM Tablasql", null);
if(c!=null)
{
switch (Tablasql.Tipo){
case 1:
nota = "Persona1: "+c.getString(c.getColumnIndex("Nombre"));
nota = "Telefono: +c.getString(c.getColumnIndex("Telefono"));
break;
case 2:
nota = "Persona2: "+c.getString(c.getColumnIndex("Nombre"));
nota = "Telefono: +c.getString(c.getColumnIndex("Telefono"));
break;
}
c.close();
bd.close();
I clarify that in the switch where I put Tablasql.Type is:
public class Inicio_Detalle_Caso {
public static final String Tablasql="Tablasql";
public static final String id="id";
public static final String Telefono="Telefono";
public static final String Nombre="Nombre";
public static final String Tipo="Tipo";
public static final String creart="create table Tablasql"+Tablasql+"("+id+" integer, "+Telefono+" text, "+
Nombre+" text, "+Tipo+" integer)";
}