1. Are you ready for the Galaxy S20? Here is everything we know so far!

ContactList

Discussion in 'Android Development' started by perica0001, Dec 1, 2009.

  1. perica0001

    perica0001 Lurker
    Thread Starter

    Hi,
    I am new beginner in android developing and I have some beginner questions.
    I want to make context menu on contacts (in my phone) but I don't no
    how to get Contact List in my applications. I don't no how to get contacts...
    Can anybody help me to solve this problem ?
    Of course if somebody know some link or .pdf file for beginners let me know and post this here.
    Tnx!
     



    1. Download the Forums for Android™ app!


      Download

       
  2. racsus

    racsus Lurker

    I am in the same situation.
     
  3. Broto25

    Broto25 Lurker

    Cursor peopleCursor = managedQuery(
    ContactsContract.Contacts.CONTENT_URI, null, null, null, null);

    while (peopleCursor.moveToNext()) {

    String id = peopleCursor.getString(peopleCursor
    .getColumnIndex(ContactsContract.Contacts._ID));

    String name = peopleCursor.getString(peopleCursor
    .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

    String hasPhoneNumberFlag = peopleCursor
    .getString(peopleCursor
    .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
    }



    Doing it you get all the contacts from your phone ( ID, NAME and a Flag saying if this contact's got any phone numbers) . It's just one way to get all the contacts one by one!
     

Share This Page

Loading...