1
I made an APP that saves the date and a series of numbers (8 numbers) in the Android database. I created an object ( with date and numbers), but when I search all objects inside the database and put in a list it returns the addresses saved.
Code of the select function:
public List<Hinos> selectHinos() {
List<Hinos> lstHinos = new ArrayList<Hinos>();
SQLiteDatabase db = getReadableDatabase();
String sqlSelect = "SELECT * FROM Historico";
Cursor c = db.rawQuery(sqlSelect, null);
if (c.moveToFirst()) {
do {
Hinos hino = new Hinos();
hino.setId(c.getInt(0));
hino.setData(c.getString(1));
hino.setH1(c.getString(2));
hino.setH2(c.getString(3));
hino.setH3(c.getString(4));
hino.setH4(c.getString(5));
hino.setH5(c.getString(6));
hino.setH6(c.getString(7));
hino.setH7(c.getString(8));
hino.setH8(c.getString(9));
lstHinos.add(hino);
} while (c.moveToNext());
}
db.close();
return lstHinos;
}
Receiving the return (list) I treat this way by putting in a list view:
HinosDAO dao = new HinosDAO(this);
List<Hinos> histo= dao.selectHinos();
dao.close();
adapter = new ArrayAdapter<Hinos>(Historico.this,android.R.layout.simple_list_item_1,histo);
historico.setAdapter(adapter);
But in my list view appears:
com.estudo.app.historicootd.Objetos.Hinos@b706da7,
com.estudo.app.historicootd.Objetos.Hinos@42a3666,
com.estudo.app.historicootd.Objetos.Hinos@671c254,
com.estudo.app.historicootd.Objetos.Hinos@89d85fd
Ar Cantoni Thank you very much...was that detail even was just edit as wanted the output within the class that worked. Thanks msm saved the day kkk
– J Curiosidades