title: Get the contact details of a person from contact picker intent
body: <p>I'm trying to access the contact name,  phone number, and address of a person which I selected from contact picker intent.<br>
  Here is the code which I am using to open the contact picker Intent :</p>
  
  <p>Here is the code which I am using :</p>
  
  <pre><code>Intent intent = new Intent(Intent.ACTION_PICK, 
  ContactsContract.Contacts.CONTENT_URI);
      startActivityForResult(intent, PICK_CONTACT);
  
  case PICK_CONTACT:
          if (resultCode == Activity.RESULT_OK) {
  
            System.out.println("in on ActivityResult");
            Uri contactData = data.getData();
            Cursor c = getActivity().managedQuery(contactData, null, 
  null, null, null);
            if (c.moveToFirst()) {
          String id = 
  c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts._ID));StringhasPhone=c.getString(c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
  
              if (hasPhone.equalsIgnoreCase("1")) {
                Cursor phones             getActivity().getContentResolver().query(ContactsContract.CommonDataKind    s.Phone.CONTENT_URI,
                null,
                ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                    + " = " + id, null, null);
            phones.moveToFirst();
            String cNumber = 
  phones.getString(phones.getColumnIndex("data1"));String name phones.getString(phones.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
            //here you can find out all the thing.
            System.out.println("NAME:"+name);
          }Cursor postal_cursor=getActivity().getContentResolver().query(ContactsContract.Data.CONTENT_URI,
              new String[]{ 
   ContactsContract.CommonDataKinds.StructuredPostal.STREET,
  
  ContactsContract.CommonDataKinds.StructuredPostal.CITY,
  
  
  ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS},
              ContactsContract.Data.CONTACT_ID + "=? AND " +
  
  ContactsContract.CommonDataKinds.StructuredPostal.MIMETYPE + "=?",
              new String[]{String.valueOf(id), 
  ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE},
              null);
          postal_cursor.moveToFirst();
          while(postal_cursor.moveToNext())
          {
            String Strt = 
  postal_cursor.getString(postal_cursor.getColumnIndex(
  
  ContactsContract.CommonDataKinds.StructuredPostal.STREET));
            String Cty = 
   postal_cursor.getString(postal_cursor.getColumnIndex(
  
  ContactsContract.CommonDataKinds.StructuredPostal.CITY));
            String cntry = 
   postal_cursor.getString(postal_cursor.getColumnIndex(
  
   ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY));
            String address = 
  postal_cursor.getString(postal_cursor.getColumnIndex(
                ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS));
          }
          postal_cursor.close();   }
  </code></pre>
  
  <p>but I am not able to get the address which is stored. </p>
  
  <p>Any help is appreciated. Thanks</p>