0

I want to get all contacts in device. So I queried contacts by ContentResolver as below. But contacts from facebook were not appeared while the default contact app in android is showing every contacts. Because default contact app is showing contacts from facebook, I thought that the contacts must be inserted in db that ContactProvider accessing, so there must some way to get them.

(Because google has disabled synchronizing facebook contact, I synchronized facebook contacts by clicking synchronizing contact button in facebook app.)

So..my question is..How can I get contacts from facebook. Thanks..!!

Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;

String[] projection = new String[] {
        ContactsContract.CommonDataKinds.Phone.CONTACT_ID,      
        ContactsContract.CommonDataKinds.Phone.NUMBER,
        ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME
};


Cursor contactCursor = getContentResolver().query(uri, projection, null, null, null);

if (contactCursor.moveToFirst()) {
    do {

       // get contacts...

    } while (contactCursor.moveToNext());
}
contactCursor.close();
Lee Jeongmin
  • 793
  • 11
  • 22

1 Answers1

1

This question may help. I was looking for an app to do something like this some time ago, and I stumbled upon some information about Facebook having updated their privacy policy to prevent apps from accessing to phone numbers and email addresses on friend lists. Maybe this discussion will also be of help on that. Good luck! :)

Community
  • 1
  • 1
ayePete
  • 411
  • 1
  • 7
  • 23
  • Thanks for your comment. I found another information here.. http://stackoverflow.com/questions/4506571/how-to-get-a-contacts-facebook-id-or-url-from-native-contacts-content-resolve May be I have to get contact by facebook sdk. – Lee Jeongmin Aug 24 '15 at 09:59