Actually I can do a loop and log in console all rows of my table:
db.getAllPoids();
List<Poids> poids = db.getAllPoids();
for (Poids val : poids) {
String log = "Id: " + val.getId() + " ,Date: " + val.getDate_enr() + " ,Poids: " + val.getPoids() + " ,Evolution: " + val.getEvolution() ;
// Writing Contacts to log
Log.d("Name: ", log);
}
DatabaseHandler:
public List<Poids> getAllPoids() {
List<Poids> poidsList = new ArrayList<Poids>();
// Select All Query
String selectQuery = "SELECT * FROM " + TABLE_POIDS;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Poids poid = new Poids();
poid.setId(Integer.parseInt(cursor.getString(0)));
poid.setPoids(Integer.parseInt(cursor.getString(1)));
poid.setDate_enr(cursor.getString(2));
poid.setEvolution(cursor.getString(3));
poid.setId_utilisateurs(Integer.parseInt(cursor.getString(4)));
// Adding contact to list
poidsList.add(poid);
} while (cursor.moveToNext());
}
But now Iwan't to do a better view, I need something like a table or liste, I know that they're listview exemple on google, but not with this method that I use.
And in my view I need to have3 rows: get the date in the first, the row "poids" in the second and n image view containing the id to delete the row on click. It is possible ? I don't know how to do.
Aucun commentaire:
Enregistrer un commentaire