0
I’m studying programming for Android, I’m making a query in the database Sqlite, however I can not play the data obtained in a listview, it always returns me my string in full instead of the value of the bank.
This is my function that makes select
private boolean VerificaRegistro(){
try{
BancoDados = openOrCreateDatabase(NomeBanco, MODE_PRIVATE ,null);
cursor = BancoDados.rawQuery("select * from tabcadastropessoa", null);
if(cursor.getCount()!=0){
cursor.getCount();
cursor.moveToFirst();
return true;
}
else
{
return false;
}
}catch(Exception erro){
MensagemAlerta("Erro no Banco de Dados", "Não foi possível gverificar dados"
+ erro);
return false;
}
finally{
BancoDados.close();
}
}
This is my function to list in listview
public void CarregaDados(){
lista = (ListView)findViewById(R.id.LvMostraDados);
VerificaRegistro();
String[] Coluna = new String[]{"nomepessoa"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
Coluna);
lista.setAdapter(adapter);
}
This is the image of how the data returns to me
Tiago, where you are filling your object to show in the listview?
– Wellington Avelino
You are passing "Column" as an attribute to inflate your listview, put your Adapter source code so we can take a look.
– Wellington Avelino
You go to the bank only through
VerificaRegistro()
but it does not return any data, only checks if there are.– ramaral