开发者

How to add manually contacts group to Android database?

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜