How do I convert a getString to a getChar in Androdi Studio (list)

1

In this list event I want to convert the part of a getString to a getChar but I do not recognize it as char, how would its syntax be?

public List listar(){
        List<BobConstruye> d=null;
        try {

            BDatos bddatos = new BDatos(this, "bdaula11.db", null, 1);
            SQLiteDatabase bd = bddatos.getWritableDatabase();
            Cursor datos = bd.rawQuery("select raza, peso,edad"+"sexo,finalidad, from ANIMALIA", null);

            if (datos.moveToFirst()) {
                d=new ArrayList<>();
                do{
                    BobConstruye a = new BobConstruye();
                    a.setRaza(datos.getString(datos.getColumnIndex("raza")));
                    a.setEdad(datos.getString(datos.getColumnIndex("edad")));
                    a.setPeso(datos.getString(datos.getColumnIndex("peso")));
                    a.setFinalidad(datos.getChar(datos.getColumnIndex("finalidad")));
               //     a.setFinalidad(datos.getchar.getColumnIndex("finalidad"));

                    d.add(a);
                }while(datos.moveToNext());

            } else {
                Toast.makeText(this,"No hay registros",Toast.LENGTH_LONG).show();
            }
            bd.close();
        }catch (Exception e){
            Toast.makeText(this,e.getMessage(),Toast.LENGTH_LONG).show();


        }

        return  d;
    
asked by Andreso 29.11.2017 в 17:57
source

1 answer

0

You can convert it in this way, example:

String s = "Andreso";
//Convierte String a Char.
Char c = s.charAt(0);

therefore in your code it would be:

  a.setFinalidad(datos.getChar(datos.getColumnIndex("finalidad")).charAt(0));
    
answered by 29.11.2017 в 18:06