Problem in ContactsContract API android
<p>i have an HTC legend.In its phone contacts it shows 4-5 contacts.But when i query it in my application it shows nearly 45 contacts.I think its  gmail contacts.</p>

<blockquote>
<pre><code>   String[] Projection = new String[] { ContactsContract.Contacts._ID, 
            ContactsContract.Contacts.DISPLAY_NAME, 
            ContactsContract.Contacts.PHOTO_ID,
            ContactsContract.Contacts.HAS_PHONE_NUMBER,
            ContactsContract.Contacts.STARRED};
</code></pre>
  
  <p>Cursor cursor = managedQuery(ContactsContract.Contacts.CONTENT_URI, Projection, null, null, null);</p>
</blockquote>

<p>I am getting all the details with photo as well in a listview. Now i need to get particular contact details like all his phone numbers,emails,photo etc.For this i am writing this query</p>

<blockquote>
<pre><code>    final String[] projection = new String[] {
            ContactsContract.CommonDataKinds.Phone.CONTACT_ID,
            ContactsContract.CommonDataKinds.Phone.TYPE,
            ContactsContract.CommonDataKinds.Phone.NUMBER,
            ContactsContract.CommonDataKinds.Phone.IS_PRIMARY,
    };
    final Cursor phone = managedQuery(
            ContactsContract.CommonDataKinds.Phone.CONTENT_URI,  
            projection,
            ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=?",
            new String[]{contactId},
            null);
</code></pre>
</blockquote>

<pre><code>&gt; if(phone.moveToFirst()) {
&gt;             final int contactNumberColumnIndex =
&gt; phone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
&gt;             final int contactTypeColumnIndex =
&gt; phone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE);
</code></pre>

<p>i am getting all the details of the phone contact but not all other contacts.
i have read that all these details are stored in  shared table(ContactsContract.Data.CONTENT_URI), but i am not getting exactly  what to do go get this done.</p>

<p>Can someone help me figure out how to do this.</p>

<p>Thanks</p>
