I want to define some Contact Groups.
I am wondering where and how does Android store th开发者_C百科e groups. Maybe in a Sqlite database?
If so, will be able to run a insert on it?Otherwise how do you add new Contacts Group via the emulator?
You definitely can't do an insert directly. You need to look into ContentProviders, Contacts.Groups and ContactsContract.
To add a contact group programmatically:
ContentValues cv = new ContentValues();
cv.put(ContactsContract.Groups.TITLE, groupName);
cv.put(ContactsContract.Groups.GROUP_VISIBLE, 1);
getContentResolver().insert(ContactsContract.Groups.CONTENT_URI, cv);
精彩评论