I have an intoento problem to make a query and print it in an Edit Text. But I get a message in the Edit Text instead of my query. This is my method to make the query.
public String[] ob_lab(){
objBD = new Bd(nContext, "Laboratorios", null, 1);
db = objBD.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT Descripcion FROM Laboratorios WHERE ID = (SELECT MAX(ID) FROM Laboratorios);", null);
cursor.moveToFirst();
ArrayList<String> names = new ArrayList<>();
while(!cursor.isAfterLast()) {
names.add(cursor.getString(cursor.getColumnIndex("Descripcion")));
cursor.moveToNext();
}
cursor.close();
return names.toArray(new String[names.size()]);
}
in this other I call it to print it
public class consulta extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_consulta);
TextView Lab=(TextView)findViewById(R.id.lab_con);
ConexionBD O1=new ConexionBD(this);
O1.ob_lab();
Lab.setText(O1.toString());
and this appears in the TextView
! ( link )