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
Highlighted
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810
Accepted Solution

searching for the same contact over and over

Hi.

 

Sorry if I missed something so trivial that could invalidate this question, but - well I missed it Smiley Happy 

 

My app constantly looks for the same Contact in the ContactList.

 

Is there any better way to find a contact -> O(1) than to go thorugh the whole list -> O(n) ? 

 

Some kind of index? or an advanced search option I oversaw ?

 

Usually I add a contact and after some time I need to access it once again.

Sometimes it's in the same application run, sometimes it's not 

 

Thanks 



"Listen carefully, I shall say this only once"
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: searching for the same contact over and over

I found more information...

Retreive Name from Phone Number

 

That was a part of something I need.

 

I am wondering.... I am also involved in developing for Symbian. It has an option to find a contact by phone number using NATIVE serach. By native search I mean the same one their phone uses when matching incoming call phone number with the address book items.

 Now isn't that convenient Smiley Happy 

 

That's exactly what I would need.

 

The aforementioned thread explained a need for searching by phone number and a way around the limitation not having one. 

 

I guess this thread's question should now be changed to:

Is there a way to find a contact by phone number with O(f(n)) < O(n) or are we destined to use the 'second address book' workaround ?

 

P.S. btw how many of the last phone number digits is it 'safe' to match to be certain about the match (my guess 7)?

  



"Listen carefully, I shall say this only once"
BlackBerry Development Advisor
Posts: 15,211
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: searching for the same contact over and over

The method outlined in the thread you quote is the recommended approach.

 

Regarding the matching of the last phone number, you could perform the search based on the last 4 digits and then perform a more detail string match of the results returned within your application.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: searching for the same contact over and over

Is there an addressbookchangelistener or something to allow your local index to stay current?

If so, that is essentially the custom database others have been looking for. That is, you go through your

data source ( contact list, xml file, whatever) and create a persistent index of some type suited to your

needs. Some of the RIM classes I cited earlier should make good bases from which to do this in java.

 

I've been generally impressed with the speed of even my 7130 and thought most stuff was IO limited.

I would have thought that brute force sequential searches would be acceptable for many address books.

 

BlackBerry Development Advisor
Posts: 15,211
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: searching for the same contact over and over

Yes, the PIMListListener interface can be used to listen for modifications for any PIM items (contacts, events, tasks and memos).
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker