我需要访问黑莓中的联系人列表,我编写了以下代码来做到这一点:
private void readContacts() {
try {
PIM pim;
pim = PIM.getInstance();
String lists[] = pim.listPIMLists(PIM.CONTACT_LIST);
for (int i = 0; i < lists.length ; i++) {
clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,
PIM.READ_ONLY, lists[i]);
Enumeration cenum = clist.items();
while (cenum.hasMoreElements()) {
Contact c = (Contact) cenum.nextElement();
ContactDTO contact = new ContactDTO();
parseContactInfo(c, contact);
contacts.addElement(contact);
}
clist.close();
}
} catch (Exception e) {
}
}
在 j2me 中,此代码同时访问 sim 和电话联系人,但在黑莓中,它仅访问电话联系人。
String lists[] = pim.listPIMLists(PIM.CONTACT_LIST);
lists.length
返回 1
如何在黑莓中访问 sim 联系人?提前致谢。