title: Android: loading contacts with CursorLoader, not all being loaded
body: <p>My android app is supposed to load all contacts recorded in the device and display them in a list. I haven't been able to figure out why, but not all contacts are being loaded.</p>
  
  <p>Here is the code I'm using to start the query with a CursorLoader:</p>
  
  <pre><code>public android.support.v4.content.Loader&lt;Cursor&gt; onCreateLoader(int id, Bundle args) {
  
          if (id == ContactsQuery.QUERY_ID) {
              Uri contentUri;
  
  
              if (mSearchTerm == null) {
                  contentUri = ContactsQuery.CONTENT_URI;
              } else {
                  contentUri =
                Uri.withAppendedPath(ContactsQuery.FILTER_URI, Uri.encode(mSearchTerm));
          }
  
          return new CursorLoader(getActivity(),
                  contentUri,
                  ContactsQuery.PROJECTION,
                  ContactsQuery.SELECTION,
                  null,
                  ContactsQuery.SORT_ORDER);
  </code></pre>
  
  <p>ContactsQuery is defined as follows:</p>
  
  <pre><code>public interface ContactsQuery {
  
      final static int QUERY_ID = 1;
  
      final static Uri CONTENT_URI = Contacts.CONTENT_URI;
  
      final static Uri FILTER_URI = Contacts.CONTENT_FILTER_URI;
  
      @SuppressLint("InlinedApi")
      final static String SELECTION =
              (Utils.hasHoneycomb() ? Contacts.DISPLAY_NAME_PRIMARY : Contacts.DISPLAY_NAME) +
              "&lt;&gt;''" + " AND " + Contacts.IN_VISIBLE_GROUP + "=1";
  
      @SuppressLint("InlinedApi")
      final static String SORT_ORDER =
              Utils.hasHoneycomb() ? Contacts.SORT_KEY_PRIMARY : Contacts.DISPLAY_NAME;
  
      @SuppressLint("InlinedApi")
      final static String[] PROJECTION = {
  
              // The contact's row id
              Contacts._ID,
  
              Contacts.LOOKUP_KEY,
  
              Utils.hasHoneycomb() ? Contacts.DISPLAY_NAME_PRIMARY : Contacts.DISPLAY_NAME,
  
              Utils.hasHoneycomb() ? Contacts.PHOTO_THUMBNAIL_URI : Contacts._ID,
  
              SORT_ORDER,
      };
  
      final static int ID = 0;
      final static int LOOKUP_KEY = 1;
      final static int DISPLAY_NAME = 2;
      final static int PHOTO_THUMBNAIL_DATA = 3;
      final static int SORT_KEY = 4;
  }
  </code></pre>
  
  <p>Why aren't all contacts being loaded when mSearchTerm is null?</p>