Fetch Contacts in android application

前端 未结 5 492
谎友^
谎友^ 2020-12-15 07:17

I was following these links to get the contacts in my application

How to call Android contacts list?

http://www.higherpass.com/Android/Tutorials/Working-Wit

5条回答
  •  情话喂你
    2020-12-15 08:03

    Try the code below:

    ContentResolver contactResolver = getContentResolver();     
    Cursor cursor = contactResolver.query(Phone.CONTENT_URI, null, Phone.DISPLAY_NAME + "=?", new String[]{contactName}, null);    
    if(cursor.getCount() > 0){    
        cursor.moveToFirst();    
        do {    
           String number = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));    
        }while (cursor.moveToNext() );     
    }
    

提交回复
热议问题