Чтение контактного номера.
int number = contact.countValues(BlackBerryContact.TEL);
Hashtable multipleContactNumbers = new Hashtable();
for (int i = 0; i < number; i++) {
if (contact.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_WORK) {
multipleContactNumbers.put("Work: ", contact.getString(
BlackBerryContact.TEL, i));
} else if (contact.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_WORK2) {
multipleContactNumbers.put("Work 2: ", contact.getString(
BlackBerryContact.TEL, i));
} else if (contact.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_HOME) {
multipleContactNumbers.put("Home: ", contact.getString(
BlackBerryContact.TEL, i));
} else if (contact.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_HOME2) {
multipleContactNumbers.put("Home 2: ", contact.getString(
BlackBerryContact.TEL, i));
} else if (contact.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_MOBILE) {
multipleContactNumbers.put("Mobile: ", contact.getString(
BlackBerryContact.TEL, i));
} else if (contact.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_OTHER) {
multipleContactNumbers.put("Other: ", contact.getString(
BlackBerryContact.TEL, i));
}
}
Добавить новые контактные телефоны.
contact.addString(Contact.TEL, Contact.ATTR_HOME, "5555550100");
contact.addString(Contact.TEL, Contact.ATTR_WORK, "5555550103");
contact.addString(Contact.TEL, BlackBerryContact.ATTR_WORK2, "5555550104");
обновить контактные телефоны.
int telCount = contact.countValues(Contact.TEL);
for (int i = 0; i < telCount; ++i)
{
int telAttrs = contact.getAttributes(Contact.TEL, i);
if ((telAttrs & Contact.ATTR_MOBILE) != 0)
{
contact.setString(Contact.TEL, i, Contact.ATTR_MOBILE, "5555550109");
break;
}
}