Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
gmuhammad
Posts: 55
Registered: ‎07-30-2009
My Device: Not Specified
Accepted Solution

How to get email2 and mobile2 from phonebook contact

Hi,

 

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

 

Thanks,

-gmuhammad.

Please use plain text.
Developer
vivart
Posts: 147
Registered: ‎08-27-2010
My Device: 9800
My Carrier: airtel

Re: How to get email2 and mobile2 from phonebook contact

 

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());
         }
     }

 

 

Please use plain text.
Developer
gmuhammad
Posts: 55
Registered: ‎07-30-2009
My Device: Not Specified

Re: How to get email2 and mobile2 from phonebook contact

Thanks vivart, but should I use the same for mobile? because there are several phone numbers against the BlackberryContact.TEL field and I do not know the exact index for mobile2.

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get email2 and mobile2 from phonebook contact

you can try adressing the numbers by using the values of the constants instead of the names. WORK2 for example is 33554432. if (contactList.isSupportedAttribute(BlackBerryContact.TEL, 33554432)){ ... }
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
gmuhammad
Posts: 55
Registered: ‎07-30-2009
My Device: Not Specified

Re: How to get email2 and mobile2 from phonebook contact

[ Edited ]

Thanks Simon for reply but there is no constant field like BlackberryContact.MOBILE2 or attribute like BlackBerryContact.ATTR_MOBILE2

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get email2 and mobile2 from phonebook contact

it is, in OS 6: int net.rim.blackberry.api.pdap.BlackBerryContact.ATTR_MOBILE2 = 67108864 [0x4000000]
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
gmuhammad
Posts: 55
Registered: ‎07-30-2009
My Device: Not Specified

Re: How to get email2 and mobile2 from phonebook contact

Thanks simon, thank you for the information.

Please use plain text.