I made an APP that saves the date and a string of numbers (8 numbers) in the Android database. I created an object (with date and numbers), but when I go to search all objects inside the Database and put a list it returns the addresses saved.
Function code select:
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;
}
Getting the return (list) I deal like this by putting it 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 it 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