//
PIM pim = PIM.getInstance();
ContactList lists = null;
try {
// lists
lists = (ContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
} catch (Exception e) {}
//
Enumeration contacts = null;
try {
contacts = lists.items();
} catch (PIMException ex) {
ex.printStackTrace();
}
//
Contact next = (Contact) contacts.nextElement();
//
int count = next.countValues(Contact.TEL);
String all_telephone = "";
for (int i = 0; i < count; i++) {
//
String phone = next.getString(Contact.TEL, i);
all_telephone += phone+"\n";
}
list = new StringItem("List:", all_telephone);
// ,
Contact create_next = lists.createContact();
int attrs = Contact.ATTR_HOME;
//
create_next.addString(Contact.TEL, attrs, "9379992");
//
create_next.addString(Contact.ORG, PIMItem.ATTR_NONE, " ");
try {
//
create_next.commit();
} catch (PIMException ex) {
ex.printStackTrace();
}
Source: https://habr.com/ru/post/81726/
All Articles