I have a problem with the android cursor looping twice, even though I know there is only one value returned in the cursor.getCount().
I'm using the following in the DBAdapter:
public Cursor getAllSubDetailsFromObsTable() { Cursor c = mDb .rawQuery( "SELECT DISTINCT sub.sub_id, sub.complete, mobileobs.date, mobileobs.location, mobileobs.grid_ref, " + "mobileobs.time, mobileobs.protocol_id, mobileobs.endtime FROM sub, mobileobs " + "WHERE sub.sub_id = mobileobs.sub_id", null); return c; } Then I call this within my worker class with:
db.open(); Cursor c = db.getAllSubDetailsFromObsTable(); while (c.moveToNext()) { String sub_id = c.getString(0); //Rest of real code <snipped> myArrayList.add(sub_id); } c.close(); db.close(); However, when I look at the contents of myArrayList, it has two identical values of sub_id. I have tried mucking about with c.moveToFirst() etc. etc. but I still get two values in the arrayList even though c.getCount() = 1!