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
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Contact lookup. what is the best method?

Currently i'm using this to search for a contact.  the find_number is format like this 8001234567

 

 

PIM pim = PIM.getInstance(); String[] lists = pim.listPIMLists(PIM.CONTACT_LIST); for (int i = 0; i < lists.length; i++) { BlackBerryContactList list = (BlackBerryContactList)pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY, lists[i]); for (Enumeration e = list.items(find_number, BlackBerryContactList.SEARCH_CONTACTS); e.hasMoreElements(); ) { } . . . }

 

 Some users have reported that the search does not work. Does the search look at all the phone fields? does it matter what format type is in the Contacts? eg: 1.800.123.4567, 1-800-123-4567, 1(800)123-4567

 

 

 

BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Contact lookup. what is the best method?

Yes, the format of the phone number does have to match.  Meaning if a user has a number entered liked (800) 555-1234 and you search for 800-555-1234 you won't get a match.

 

Instead, you could search for a substring of the phone number (such as the last 4 digits) and then parse the digits from the contacts that are returned to see if it matches the digits you are looking for (compare after removing all non numeric characters).

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