bvv
bvv

Reputation: 1903

How get contacts from different sources (facebook and other)

How get contacts from different sources (facebook and other). This code i get contacts from sim, phone and google. How i can get contacts from facebook and other? In phonebook these contacts have.

ContentResolver cr = context.getContentResolver();
        Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);

        if (cursor.getCount() > 0) {
            while (cursor.moveToNext()) {
                //logic
           }
        }

Upvotes: 1

Views: 122

Answers (1)

nitzanj
nitzanj

Reputation: 1699

You can access the raw contacts directly instead of the automatically-aggregated contacts - http://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html.

Each account installed on the devices has it's own raw contacts. Note though that this means you get multiple raw-contacts for each actual contact.

Another thing to consider is that some accounts are private and their raw contacts are invisible to other apps. There's no way to reach those contacts without root. If I'm not mistaken that's the case with Facebook.

Upvotes: 1

Related Questions