Skip to content Skip to sidebar Skip to footer

Android: Accessing And Querying Properly Using Raw Contact Id

So my app is attempting to integrate a sync adapter to the android native contact manager. This is all running smoothly except once a contact is synced, I am unable to update it. D

Solution 1:

The lookupRawContactId method should look like this instead:

privatestaticlonglookupRawContact(ContentResolver resolver, String username) {
    Log.e("Looking up Raw Contact", username);
    longauthorId=0;
    Cursorcursor= resolver.query(RawContacts.CONTENT_URI, UserIdQuery.PROJECTION, UserIdQuery.SELECTION, newString[] {username}, null);

    try {
        if(cursor != null && cursor.moveToFirst()) {
            authorId = cursor.getLong(UserIdQuery.COLUMN_ID);
        }
    } finally {
        if(cursor != null) {
            cursor.close();
        }
    }
    return authorId;
}

Notice the query is searching RawContacts.CONTENT_URI instead.

Post a Comment for "Android: Accessing And Querying Properly Using Raw Contact Id"