Android get phone number from contact list
<p>I have these codes which basically use a ListView to display the names in the contact list and I want to get their phone number when click each single name:</p>

<pre><code>final ContentResolver cr = getContentResolver();

final Cursor c = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
myCursorAdapter = new SimpleCursorAdapter(this, R.layout.list_item, c, new String[] {ContactsContract.Contacts.DISPLAY_NAME}, new int[]{R.id.TVRow}, 0);
myPhoneList.setAdapter(myCursorAdapter);

myPhoneList.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override
    public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id){
        c.moveToPosition(position);
        Toast.makeText(getApplicationContext(), c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)), Toast.LENGTH_SHORT).show();
    }
});
</code></pre>

<p>In the <code>onItemClick</code> Method the </p>

<pre><code>    GetColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)
</code></pre>

<p>returns -1 and therefore I cannot get the phone number with this method.</p>

<p>I've also tried to print out all the columns of the cursor <code>c</code> and it returns 34 columns but the only column which seems to be related to the phone number is <code>HasPhoneNumber</code>.</p>

<p>So where's the problem and how can I fix it? Thanks!</p>

<hr>

<p>The updated version, where the <code>String</code> array passed to construct <code>myCursorAdapter</code> is changed:</p>

<pre><code>final ContentResolver cr = getContentResolver();

    final Cursor c = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
    myCursorAdapter = new SimpleCursorAdapter(this, R.layout.list_item, c, new String[] {ContactsContract.CommonDataKinds.Phone.NUMBER}, new int[]{R.id.TVRow}, 0);
    myPhoneList.setAdapter(myCursorAdapter);

    myPhoneList.setOnItemClickListener(new AdapterView.OnItemClickListener(){
        @Override
        public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id){
            c.moveToPosition(position);
            Toast.makeText(getApplicationContext(), c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)), Toast.LENGTH_SHORT).show();
        }
    });
</code></pre>

<p>I suppose the updated code will show the phone numbers in the ListView but I got an error says "column 'data1' does not exist".</p>