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
Pif
Contributor
Pif
Posts: 31
Registered: ‎08-31-2010
My Device: Simulator

Select contact from AddressVook by number or Email

Is there any fast way of getting Contact from AddressBook by telephone or email?

Please use plain text.
Developer
simon_hain
Posts: 15,999
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Select contact from AddressVook by number or Email

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/blackberry/api/pdap/BlackBerryContactList...(java.lang.String, int)

----------------------------------------------------------
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.
Pif
Contributor
Pif
Posts: 31
Registered: ‎08-31-2010
My Device: Simulator

Re: Select contact from AddressVook by number or Email

tnx for the link)

I was reading that api for several days)

 

I know about items() method.

But it's not that quick.

 

The problem in details is the following:

I have a Vector of several numbers/emails which are not pinned to any contact information (like UID or smth else).

And for every element from Vector (e.g.: "hello@world.com", "456123789",..) I should find corresponding name (and show it often further).

 

I work with a huge (2000) Address book.

Please use plain text.
Developer
simon_hain
Posts: 15,999
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Select contact from AddressVook by number or Email

for a quick check by number you can do this:

create a http://www.blackberry.com/developers/docs/5.0.0api/net/rim/blackberry/api/phone/phonelogs/PhoneCallL... object and call getName. if the number exists in the adressbook the bb OS will populate the id object with the name associated. if getName returns null the number is not in the adressbook.

to retrieve the full contact you still have to use the contactlist, but it should be more performant.

----------------------------------------------------------
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.
Pif
Contributor
Pif
Posts: 31
Registered: ‎08-31-2010
My Device: Simulator

Re: Select contact from AddressVook by number or Email

[ Edited ]

Wow, nice! Thanks!

Such a great performance jump!

 

Is there anything similar for email?

 

Please use plain text.
Developer
simon_hain
Posts: 15,999
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Select contact from AddressVook by number or Email

nope, no such luck.

if you work with the addressbook extensively you have no other option but to copy it into a performant structure.

internally the addressbook uses a patricia tree which is quite fast - i have absolutely no clue why the API is so slow.

there have been posts about people doing exactly that, but it's been some time.

when working on os5+ it would be easier to save with sqllite, but still a lot of work to overcome a stupid API.

----------------------------------------------------------
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.