Am building an app that requires a custom contact field (\'whitelist\', if you were wondering) for every phone number.
However, I only found a way of saving custom d
All right, I figured it out. Maybe there is a better solution, but this works for me:
values.put(Data.RAW_CONTACT_ID, contactId);
values.put(Data.DATA1, phoneId);
values.put(Data.DATA2, "1");
values.put(Data.DATA5, phoneNum);
values.put(Data.MIMETYPE, MIMETYPE_WHITELIST_CONTACT);
getContentResolver().insert(Data.CONTENT_URI, values);
When I query, I just have to add the phoneId to get the result I need:
getContentResolver().query(Data.CONTENT_URI, {Data.DATA1, Data.DATA2},
Data.RAW_CONTACT_ID + " = " + contactId + " AND " +
Data.DATA1 + " = " + phoneId + " AND " +
Data.MIMETYPE + "='" + MIMETYPE_WHITELIST_CONTACT+"'", null, null);