This snippet of code I try to retrieve all the rows of the notes table but during the execution returns the number of rows are correct but all are like the last row .. I want to know what the error
public ArrayList<Note> selectAllNotes() {
Cursor cursor = dbReader.rawQuery("SELECT * FROM notes", null);
Note note = new Note();
ArrayList<Note> notes = new ArrayList<>();
while (cursor.moveToNext()) {
note.setNoteID(cursor.getInt(cursor.getColumnIndex(DbHelper.ID)));
note.setNoteTitle(cursor.getString(cursor.getColumnIndex(DbHelper.TITLE)));
note.setNoteContent(cursor.getString(cursor.getColumnIndex(DbHelper.CONTENT)));
notes.add(note);
}
return notes;
}