所以,我有一個查詢返回一個Cursor與所有值(我確認這與cursor.getCount()返回的int等於數據庫中的記錄數),但對於某些原因,無論我寫什麼迭代循環,我都永遠無法檢索列表的第一個值。光標循環迭代不顯示第一個值
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);
}
該位代碼顯示除第一個以外的所有值。我究竟做錯了什麼?我已經嘗試了很多方法,包括做,而等,但總是以同樣的錯誤結束。
我錯過了什麼?