title: retrieve multiple rows form android sqlite
body: <p>I am going to fetch some rows with specific tag in android Sqlite. 
  The problems are</p>
  
  <ol>
  <li>I got 15 with <code>cursor.getCount();</code> but 13 rows retrieved.</li>
  <li>the 13 rows just repeat last row data</li>
  </ol>
  
  <p>here is my code </p>
  
  <pre><code>public ArrayList&lt;HashMap&lt;String, String&gt;&gt; getTodo(String tag) {
      ArrayList&lt;HashMap&lt;String,String&gt;&gt; arList = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;();
      HashMap&lt;String, String&gt; todo = new HashMap&lt;String, String&gt;();
      String selectQuery = "SELECT * FROM " + TABLE_NAME + " WHERE "
                  + COLUMN_TAG + " = ?";
      String[] args={tag};
  
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor cursor = db.rawQuery(selectQuery, args);
      // Move to first row
      cursor.moveToFirst();
      System.out.println(cursor.getCount());
      if (cursor.getCount() &gt; 0) {
          do {
              todo.put(COLUMN_ID, cursor.getString(cursor.getColumnIndex(COLUMN_ID)));
              todo.put(COLUMN_FROM, cursor.getString(cursor.getColumnIndex(COLUMN_FROM)));
              todo.put(COLUMN_TO, cursor.getString(cursor.getColumnIndex(COLUMN_TO)));
              todo.put(COLUMN_TITLE, cursor.getString(cursor.getColumnIndex(COLUMN_TITLE)));
              todo.put(COLUMN_TAG, cursor.getString(cursor.getColumnIndex(COLUMN_TAG)));
  
              arList.add(todo);
          } while (cursor.moveToNext());
      }
      cursor.close();
      db.close();
      // return todo
      return arList;
  }
  </code></pre>
  
  <p>Please help. Thanks</p>