gmuhammad
gmuhammad

Reputation: 1438

How to get email2 and mobile2 from phonebook contact

Does anyone know how to get email2 and mobile2 from the phonebook? The BlackBerryContact class does not have a constant like BlackBerryContact.EMAIL for email2 and mobile2.

Upvotes: 3

Views: 313

Answers (1)

Vivart
Vivart

Reputation: 15313

    if (contacts.isSupportedField(BlackBerryContact.EMAIL)) {
             try {
                 if (contact.countValues(BlackBerryContact.EMAIL) > 0)
                     email1 = contact.getString(BlackBerryContact.EMAIL, 0);
                 System.out.println("Email1 " + email1);

                 if (contact.countValues(BlackBerryContact.EMAIL) > 1)
                     email2 = contact.getString(BlackBerryContact.EMAIL, 1);
                 System.out.println("Email2 " + email2);
             } catch (Exception e) {
                 System.out.println("Exception::" + e.getMessage());
             }
         }

if (contacts.isSupportedField(BlackBerryContact.TEL)) {
                        int count = contact.countValues(BlackBerryContact.TEL);
                        for (int i = 0; i < count; i++) {
                            int attribute = contact.getAttributes(BlackBerryContact.TEL, i);
                            if(attribute == BlackBerryContact.ATTR_MOBILE){
                                String mobile = contact.getString(BlackBerryContact.TEL,i);
                                lblField1.setText(mobile);
                            }
                            if(attribute == BlackBerryContact.ATTR_HOME){
                                String home = contact.getString(BlackBerryContact.TEL, i);
                                lblField2.setText(home);
                            }
                        }

                    }

Upvotes: 3

Related Questions