Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following code will fetch all the contacts in an android device. </p> <pre><code>public class GetContactFromLookup extends Activity { int CONTACTS_REQUEST_CODE =1; static ContentResolver cr; Activity thisActivity; /** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.test); thisActivity = this; Button btn = (Button)findViewById(R.id.button1); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intent, 1); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case 1 : if (resultCode == Activity.RESULT_OK) { Uri uri = data.getData(); List&lt;String&gt; items = uri.getPathSegments(); String lookup_key = items.get(2); Log.v("", "id--&gt;"+items.get(2)); Uri myContacts = ContactsContract.CommonDataKinds.Phone.CONTENT_URI ;//People.CONTENT_URI; Cursor mqCur = managedQuery(myContacts, null, null, null, null); if(mqCur.moveToFirst()) { do { String contact_id = mqCur.getString(mqCur .getColumnIndexOrThrow(ContactsContract.Contacts.LOOKUP_KEY)); if(lookup_key.equals(contact_id)){ String phone_no = mqCur.getString(mqCur .getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER)); Log.v("", "phone_no--&gt;"+phone_no); } } while(mqCur.moveToNext()); } } } super.onActivityResult(requestCode, resultCode, data); } } </code></pre> <p>I think this will help you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload