title: Retrieving Contact by PHONE.CONTENT_URI returns duplicate rows
body: <p>I am trying to retrieve phone numbers from my raw contact by account type.
  Using the snippet below,</p>
  
  <pre><code>String SELECTION =
              ContactsContract.RawContacts.ACCOUNT_TYPE + "='" + Constants.ACCOUNT_TYPE + "'";
  
      ContentResolver cr = this.getContentResolver();
      Cursor cur = cr.query(ContactsContract.RawContacts.CONTENT_URI,
              null, SELECTION, null, ContactsContract.Contacts.DISPLAY_NAME + " ASC");
      if (cur.getCount() &gt; 0) {
          while (cur.moveToNext()) {
              String type = cur.getString(cur.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE));
              String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
              //String phone = cur.getString(cur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
              Log.e("number",name);
             // hasPhoneNumber(cur.getString(cur.getColumnIndex(ContactsContract.RawContacts._ID)));
          }
          cur.close();
      }
  </code></pre>
  
  <p>I could retrieve all contact tied to the account type but, hasPhoneNumber(String contactId) returns an empty cursor.</p>
  
  <pre><code>private boolean hasPhoneNumber(String id) {
      Cursor pCur = this.getContentResolver().query(
              ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
              null,
              ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",
              new String[]{id}, null);
      while (pCur.moveToNext()) {
          String phoneNo = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
          phoneNo = phoneNo.replace(" ", "");
          if (Integer.parseInt(pCur.getString(
                  pCur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) &gt; 0) {
              Log.e("search", "found phone number");
              pCur.close();
              return true;
          }
          pCur.close();
      }
      return false;
  }
  </code></pre>
  
  <p>However, I decided to perform my query with PHONE.CONTENT_URL as:</p>
  
  <pre><code>String SELECTION =
              ContactsContract.RawContacts.ACCOUNT_TYPE + "='" + Constants.ACCOUNT_TYPE + "'";
  
      ContentResolver cr = this.getContentResolver();
      Cursor cur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
              null, SELECTION, null, ContactsContract.Contacts.DISPLAY_NAME + " ASC");
      if (cur.getCount() &gt; 0) {
          while (cur.moveToNext()) {
              String type = cur.getString(cur.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE));
              String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
              String phone = cur.getString(cur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
              Log.e("number",phone);
             // hasPhoneNumber(cur.getString(cur.getColumnIndex(ContactsContract.RawContacts._ID)));
          }
          cur.close();
      }
  </code></pre>
  
  <p>This works as expected except that I have only 3 contact that matches such query on my contact list but the while loop runs for 6 times, showing each number twice. How best can I implement this and what am i doing wrong ?</p>