Difficulties in doing an SQLite query Android

0

I am doing a project for college, but I have difficulties with SQLite queries. I wish you could help me with this.

OnCreate:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chamado);

    buscarDados();
    criaLista();

}

searchData:

public void buscarDados(){
     try{
        db = openOrCreateDatabase("cadastro",Context.MODE_ENABLE_WRITE_AHEAD_LOGGING,null);
        cursor = db.rawQuery("select * from cadastro",null);

        Toast.makeText(getApplicationContext(), "Dados encontrados", Toast.LENGTH_LONG).show();
     }catch (Exception e){
        Toast.makeText(getApplicationContext(), "Erro", Toast.LENGTH_LONG).show();
     }
}

createList:

public void criaLista(){
    lista = (ListView) findViewById(R.id.lista);

    String[] dados = {"titulo"};
    int[] to = {R.id.lista};

    adapter = new SimpleCursorAdapter(getApplicationContext(),R.layout.activity_chamado,cursor,dados,to);

    lista.setAdapter(adapter);
}
    
asked by anonymous 01.11.2016 / 00:53

0 answers