Problem Statement - Display contacts who are in one of the groups
selected by the user in preference screen. ( As it is there in the
native android contacts preference screen )
I use the following query to query the contacts
String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
+ Contacts.HAS_PHONE_NUMBER + "=1) AND ("
+ Contacts.DISPLAY_NAME + " != '' ))AND ("
+ Contacts.IN_VISIBLE_GROUP + "=1)";
Cursor contact_cursor =
getContentResolver().query(Contacts.CONTENT_URI, null, select,
null, Contacts._ID + " COLLATE LOCALIZED ASC");
this query gives me only the following columns
columnnumber 23=send_to_voicemail
columnnumber 22=photo_id
columnnumber 21=contact_status_ts
columnnumber 20=contact_status_res_package
columnnumber 19=display_name_source
columnnumber 18=contact_presence
columnnumber 17=display_name_alt
columnnumber 16=sort_key
columnnumber 15=starred
columnnumber 14=_id
columnnumber 13=in_visible_group
columnnumber 12=sort_key_alt
columnnumber 11=display_name
columnnumber 10=last_time_contacted
columnnumber 9=contact_status_icon
columnnumber 8=lookup
columnnumber 7=contact_status_label
columnnumber 6=phonetic_name_style
columnnumber 5=phonetic_name
columnnumber 4=has_phone_number
columnnumber 3 =custom_ringtone
columnnumber 2=contact_status
columnnumber 1=times_contacted
To get the group information what i do at present is to query each
contact id from (the above query) for the groups with the URI
Contacts.Data.CONTENT_URI.
Uri groups = ContactsContract.Data.CONTENT_URI;
String selected_groups = " (1, 2 , 3, 4 ,
5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,12)";
String selection = Data.MIMETYPE+ "='"
+GroupMembership.CONTENT_ITEM_TYPE+"' AND "
+GroupMembership.GROUP_ROW_ID +" IN "+ selected_groups ;
String[] Projection = new String[]
{GroupMembership.GROUP_ROW_ID,GroupMembership.GROUP_SOURCE_ID,
GroupMembership.DISPLAY_NAME,GroupMembership.RAW_CONTACT_ID,GroupMembership.PHOTO_ID};
Cursor group_cursor = getContentResolver().query(groups, Projection,
selection, null,Data.RAW_CONTACT_ID+ " COLLATE LOCALIZED ASC");
I dont think it is best to query for each contact id if it is a member
of a group or not. My problem is not about getting the group
information but getting them quickly so the the contact list gets
displayed with users filter instantly
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en