title: Displaying contacts only with phone numbers using ACTION_PICK intent in Android device
body: <p>My goal is to only display contacts with phone number to user and let user select few contacts which I want to store locally.</p>
  
  <p>I have used various options in place of ContactsContract.Contacts.CONTENT_URI in below method. But I am getting lot many of the contacts (many are junk with only email ids) displayed.</p>
  
  <pre><code>    public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.contact_selector);
  
          ((Button)findViewById(R.id.btnphonecontactlist)).setOnClickListener(new OnClickListener() {
  
           @Override
           public void onClick(View v) {
             // TODO Auto-generated method stub
             Intent contactIntent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
              startActivityForResult(contactIntent, 1);
                }
             });
      }
  </code></pre>
  
  <p>If I pass ContactsContract.Contacts.CONTENT_URI as parameter for above method and in case of below handler method,  the String[] for the query method as projection parameters (which are shown commented), the method fails with java.lang.IllegalArgumentException. If I pass null in below method, then whatever contact I select, I don't find any column related to phone number or email.</p>
  
  <pre><code>    @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
  
          if(data != null)
          {
              Uri uri = data.getData();
  
              if(uri != null)
              {
                  Cursor c = null;
  
                  try
                  {
                      c = getContentResolver().query(uri, null
                                                  // new String[] { 
                              //ContactsContract.CommonDataKinds.Phone.NUMBER, 
                              //ContactsContract.CommonDataKinds.Phone.TYPE}, 
                              , null, null, null);
  
                      if(c != null &amp;&amp; c.moveToFirst())
                      {
                          String number = c.getString(0);
                          String type = c.getString(1);
                      }               
                  }
                  finally
                  {
                      if(c != null &amp;&amp; !c.isClosed())
                          c.close();
                  }
              }
          }
      }
  </code></pre>
  
  <p>Is there any way to display only contacts visible to user usually when user goes to phone book and which has phone numbers available?</p>
  
  <p>I tried going through all the threads in stackoverflow and other sites, but could not find any solution which resolve issue around this though many people have posted the issue. I haven't worked much with the Android platform and I might have missed out certain minor details and I believe there must be an easy way to achieve this.</p>
  
  <p>Kindly suggest. Appreciate your help.</p>
  
  <p>Thanks.</p>