So, I have a query that returns a cursor with all values (I confirmed this with cursor.getCount (), where the returned int was equivalent to the number of records in the database), but for some reason no matter what iteration -loop is I write, I can never get the first value of a list.
private void addAllUnsentCrapportsToList() {
mDbAdapter.open();
Cursor cursor = mDbAdapter.getAllCrapports();
cursor.moveToFirst();
String text = "";
while(cursor.isAfterLast() == false){
text = text
+ "typ: " + cursor.getString(cursor.getColumnIndex(DbAdapter.CRAPPORT_KEY_GARBAGETYPE))
+ " kommentar: " + cursor.getString(cursor.getColumnIndex(DbAdapter.CRAPPORT_KEY_COMMENT))
+ "\n";
cursor.moveToNext();
}
unsentCrapportList.setText(text);
}
This bit of code displays all values except the first. What am I doing wrong? I tried many approaches, including doing, for now, etc., but always had the same error.
What am I missing?
source
share