title: How to get all contacts full name and phone number, only if they have a phone number?
body: <p>I am trying to get all contacts that have a phone number, and record their full name and phone number, (and in the future, their contact photo), but I am stuck. here is my code:</p>
  
  <pre><code>String contacts = "";
  
      Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null); 
      while (cursor.moveToNext()) {
         String contactId = cursor.getString(cursor.getColumnIndex( 
         ContactsContract.Contacts._ID)); 
         String hasPhone = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); 
         if (hasPhone == "1") {
             contacts += cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)) + ":" + "how to get number?" + "|";
         }
      }
      cursor.close();
  </code></pre>
  
  <p>String hasPhone should contain "1" if the contact has a phone number, then add that name and the persons phone number to the "contact" string. Even though hasPhone does contain "1", (checked from logcat) no code in the condition statement runs. Also, how do you get the phone number, there is nothing in ContactsContract.Contacts for number.</p>