, - Data, , , CONTACT_ID DISPLAY_NAME, Contacts.
, HashMap CONTACT_ID (, ).
(: , ContactsContract)
Map<Long, List<String>> contacts = new HashMap<Long, List<String>>();
String[] projection = {Data.CONTACT_ID, Data.DISPLAY_NAME, Data.MIMETYPE, Data.DATA1, Data.DATA2, Data.DATA3, Data.PHOTO_ID};
String selection = Data.MIMETYPE + " IN ('" + Phone.CONTENT_ITEM_TYPE + "', '" + Email.CONTENT_ITEM_TYPE + "')";
Cursor cur = cr.query(Data.CONTENT_URI, projection, selection, null, null);
while (cur != null && cur.moveToNext()) {
long id = cur.getLong(0);
String name = cur.getString(1);
String mime = cur.getString(2);
String data = cur.getString(3);
int type = cur.getInt(4);
String label = cur.getString(5);
long photoId = cur.getLong(6);
String kind = "unknown";
String labelStr = "";
switch (mime) {
case Phone.CONTENT_ITEM_TYPE:
kind = "phone";
labelStr = Phone.getTypeLabel(getResources(), type, label);
break;
case Email.CONTENT_ITEM_TYPE:
kind = "email";
labelStr = Email.getTypeLabel(getResources(), type, label);
break;
}
Log.d(TAG, "got " + id + ", " + name + ", " + kind + " - " + data + " (" + labelStr + ")");
List<String> infos;
if (contacts.containsKey(id)) {
infos = contacts.get(id);
} else {
infos = new ArrayList<String>();
infos.add("name = " + name);
infos.add("photo = " + photoId);
contacts.put(id, infos);
}
infos.add(kind + " = " + data + " (" + labelStr + ")");
}