Selecting only one number from a contact which is having more than two contact numbers
<p>I am able to retrieve contact name and number from contacts using following code.My problem is that when a contact has multiple numbers,it somehow selects one of them,which i don't want.</p>

<p><em><strong>If a contact has multiple phone numbers, I need the user to be able to choose which phone number he wants to select.</em></strong></p>

<p>This is my code.</p>

<pre><code>private void pickContacts() {
                // TODO Auto-generated method stub
                Intent it = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);           
                startActivityForResult(it,1);
            }
</code></pre>

<p>In onActivityResult(int requestCode,int resultCode,Intent data)</p>

<pre><code>if(requestCode==1){
        Uri contactData = data.getData();
        Cursor c = managedQuery(contactData, null, null, null, null);
        if (c.moveToFirst()) 
        {                       
            String id = c.getString(
                    c.getColumnIndex(ContactsContract.Contacts._ID));
             name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
            localEditor.putString("contactName", name);
            tv2.setText(name);      
            int hasPhone=c.getInt(c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
            if(hasPhone==1){
                 Cursor pCur = getContentResolver().query(
                         ContactsContract.CommonDataKinds.Phone.CONTENT_URI, 
                         null, 
                         ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", 
                         new String[]{id}, null);
                                while(pCur.moveToNext()){

                                     number =pCur.getString(pCur.getColumnIndex(
                                            ContactsContract.CommonDataKinds.Phone.NUMBER));
                                //  Toast.makeText(getApplicationContext(), number, Toast.LENGTH_LONG).show();

                                    localEditor.putString("contactNumber", number);

                                tv3.setText(number);

                                }
                                pCur.close();
            }
        }while(c.moveToNext());




        localEditor.commit();
      //  tv2.setText(name);     
     //   tv3.setText(number);
    super.onActivityResult(requestCode, resultCode, data);
}
</code></pre>

<p>Thank for the help in advance..</p>
