Accessing Android Contact Group Names -
can please tell me how fetch contact groups programmatically stored in our android phone?
final string[] group_projection = new string[] { contactscontract.groups._id, contactscontract.groups.title }; cursor = getcontentresolver().query( contactscontract.groups.content_uri, group_projection, null, null, contactscontract.groups.title); globalconfig.grouplist.clear(); group g = new group(); g.groupidlist += "0"; g.setgrouptitle("all"); globalconfig.grouplist.add(g); while (cursor.movetonext()) { string id = cursor.getstring(cursor .getcolumnindex(contactscontract.groups._id)); string gtitle = (cursor.getstring(cursor .getcolumnindex(contactscontract.groups.title))); if (gtitle.contains("group:")) { gtitle = gtitle.substring(gtitle.indexof("group:") + 6).trim(); } if (gtitle.contains("favorite_")) { gtitle = "favorites"; } if (gtitle.contains("starred in android") || gtitle.contains("my contacts")) { continue; } group gobj = new group(); int pos = globalconfig.groupcontainstitle(gtitle); if (pos != -1) { gobj = globalconfig.grouplist.get(pos); gobj.groupidlist += "," + id; globalconfig.grouplist.set(pos, gobj); } else { gobj.groupidlist += id; gobj.setgrouptitle(gtitle); globalconfig.grouplist.add(gobj); } // log.d("grpid title", gobj.getgroupidlist() + // gobj.getgrouptitle()); }
Comments
Post a Comment