How to access SIM contacts in Blackberry

2019-05-23 18:42发布

I need to access contact list in blackberry, I writ following code to do that:

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) {
        }
    }

In j2me this code access both sim and phone contacts but in blackberry it is accessing only phone contacts.

String lists[] = pim.listPIMLists(PIM.CONTACT_LIST);

lists.length return 1

How I can access sim contacts in blackberry?? Thanks in advance.

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-05-23 19:17

According to this post from Simon Hain, you can't:

you cannot access contacts from the sim card afaik. contacts from the addressbook can be accessed with the PIM API, check http://www.blackberry.com/developers/docs/6.0.0api/net/rim/blackberry/api/pdap/BlackBerryContactList.html

That answer was circa OS 6.0, so perhaps something that I'm not aware of got added in OS 7 (?)

查看更多
登录 后发表回答