title: Pick a Number and Name From Contacts List in android app
body: <p>i want to pick a contact with it's number from my contacts list.
  i read a lot of solutions and research for couple weeks but all of articles didn't work properly.
  some codes like following:</p>
  
  <pre><code>Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
  startActivityForResult(intent, PICK_CONTACT);
  </code></pre>
  
  <p>// and in activityresult:</p>
  
  <pre><code>if (resultCode == Activity.RESULT_OK) {
              Uri contactData = data.getData();
              Cursor c =  managedQuery(contactData, null, null, null, null);
              if (c.moveToFirst()) {
                String name = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
                tv1.setText(name);
              }
            }
  </code></pre>
  
  <p>or this code for getting all contacts but i cant have the number of contacts:</p>
  
  <pre><code>String[] contacts = new String[] {People.NAME, People.NUMBER};       
  Uri contentUri = People.CONTENT_URI;        
  Cursor cursor = managedQuery(contentUri, contacts, null, null, null);                 
  String textContacts = "";                 
  if (cursor.moveToFirst()) {         
      String myname = null;         
      String mynumber = null;         
      do {          
          textContacts = textContacts + cursor.getString(cursor.getColumnIndex(People.NAME)) + " : " + cursor.getString(cursor.getColumnIndex(People.NUMBER)) + "\n";         
      } while (cursor.moveToNext()); 
  tv1.setText(textContacts);
  }
  </code></pre>
  
  <p>can anyone help me plz? my android is 2.3.3</p>