I have a database in an application of android
, I'd like the field name in the table to fill in the text
of the TextView
. I saw some examples but I could not implement it, getReadableDatabase().rawQuery(sqlNome, null);
always turns red, ie I can not use it. It's just a given that will be in the table.
Here is the code I tried to implement:
criaBanco = new CriaBanco(getBaseContext());
sqlNome = "select nome from tabela";
Cursor cursor = getReadableDatabase().rawQuery(sqlNome, null);
textView = (TextView) findViewById(R.id.txt1);
if (!criaBanco.NOME.isEmpty()) {
textView.setText(sqlNome);
}
else {
textView.setText("NOME");
}
cursor.close();