title: Asccending order by column name using cursor
body: <pre><code>Android Studio 0.4.6
  </code></pre>
  
  <p>Hello,</p>
  
  <p>I have the following function that should get the rows of the database in ASC order based on the column name. However it just gets the rows in the order that they are listed in the database.</p>
  
  <p>So it should be in alphabetical order for names in the database.</p>
  
  <p>I think my cursor query is correct, as in the debugger the cursor value is:</p>
  
  <pre><code>SQLiteQuery: SELECT _id, name, phone, email FROM friends ORDER BY name ASC
  </code></pre>
  
  <p>Which is what I want. I then set my cursor to the first row and loop over over them until I get to the last row.</p>
  
  <p>However, it doesn't display in the alphabetical for name. </p>
  
  <pre><code>private void loadDB() {
          Cursor cursor = db.query(FriendContract.TABLE,
                  new String[] {FriendContract.Column.ID, FriendContract.Column.NAME, FriendContract.Column.PHONE, FriendContract.Column.EMAIL},
                  null, null, null, null, FriendContract.Column.NAME + " ASC");
  
          /* Check if database is empty */
          if(cursor.getCount() == 0) {
              /* There are no rows to load - so just return */
              Log.d(TAG, "loadDB() cursor.getCount() == 0. There are no rows, just just refresh listview");
              adapter.notifyDataSetChanged();
              return;
          }
  
          /* Clear all items from array list -
              we are going to fill this with the content of the database */
          friendsList.clear();
          Friend friend;
  
          cursor.moveToFirst();
          while(!cursor.isAfterLast()) {
              friend = new Friend();
              friend.setId(cursor.getLong(0));
              friend.setName(cursor.getString(1));
              friend.setPhone(cursor.getString(2));
              friend.setEmail(cursor.getString(3));
              /* Add this to the list of friends */
              friendsList.add(friend);
              cursor.moveToNext();
          }
  
          /* Clean up */
          cursor.close();
  
          /* Refresh the listview with the loaded friends */
          adapter.notifyDataSetChanged();
      }
  </code></pre>