title: Android SQLite cursor looping twice
body: <p>I have a problem with the android cursor looping twice, even though I know there is only one value returned in the cursor.getCount().</p>
  
  <p>I'm using the following in the DBAdapter:</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>Then I call this within my worker class with:</p>
  
  <pre><code>db.open();
  Cursor c = db.getAllSubDetailsFromObsTable();
  while (c.moveToNext()) {
          String sub_id = c.getString(0);
          //Rest of real code &lt;snipped&gt;
          myArrayList.add(sub_id);
  }
  c.close();
  db.close();
  </code></pre>
  
  <p>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!</p>