Skip to content Skip to sidebar Skip to footer

Can I Extend Androids Contacts Database?

I was wondering is it possible to extend the Android Contacts database? From here - http://d.android.com/reference/android/provider/ContactsContract.html It says: ContactsContract

Solution 1:

You can store custom data in the contacts database. However "when a user looks at the contacts he or she knows what users they can use my app with," may not be possible if you are thinking users will be able to see the custom data you inserted while using the built-in Android Contacts application. You would have to display the custom data in your own application.

The javadocs for the ContactsContract.Data class should provide an explanation, as well as the Contacts article.

To use this you'll need to get a raw contact id by querying the RawContacts.

Here some example code that might help you get started...

privatevoidmakePowerful(int rawContactId) {
    ContentValuesvalues=newContentValues();
    values.put(Privilege.RAW_CONTACT_ID, rawContactId);
    values.put(Privilege.MIMETYPE, Privilege.CONTENT_ITEM_TYPE);
    values.put(Privilege.PRIVILEGE_LEVEL, Privilege.TYPE_POWERFUL);
    Uriuri= getContentResolver().insert(Data.CONTENT_URI, values);
}

publicstaticfinalclassPrivilegeimplementsContactsContract.DataColumnsWithJoins, ContactsContract.CommonDataKinds.CommonColumns {
    publicstaticfinalStringCONTENT_ITEM_TYPE= ContentResolver.CURSOR_ITEM_BASE_TYPE + "/my_app_privilege";
    publicstaticfinalintTYPE_POWERFUL=1;
    publicstaticfinalintTYPE_WEAK=2;
    publicstaticfinalStringPRIVILEGE_LEVEL= DATA1;

    privatePrivilege() { }
}

Post a Comment for "Can I Extend Androids Contacts Database?"