Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Searching the Contact Database

The class CContactFindView provides a view of an existing CContactViewBase-derived object, populated using search criteria. The find view only contains Contact Items from the underlying view that match the search criteria. The find view observes its underlying view so that it is kept up to date if the contents of the underlying view change.

CContactFindView::FindL() searches the database for a text string. The function searches the fields contained in the field definition. The caller takes ownership of the returned object. There is a limit of 255 characters on the search string length.

Email addresses are looked-up as follows:

_LIT(KEmailAddressToLookup,”[email protected]”);
CContactDatabase* database = CContactDatabase::OpenL();
CContactTextDef* def=CContactTextDef::NewL();
def->Append(KUidContactFieldEMailValue);
CContactIdArray* results;
results=database->FindLC(KEmailAddressToLookup, def);

CContactDatabase::MatchPhoneNumberL() returns an array of IDs for all the Contact Items that may contain the specified telephone number in a telephone, fax or SMS type field. The number is compared starting from the right side of the number field. The method returns an array of candidate matches.

The recommended way to look up a contact ID that corresponds to a phone number is shown below. This example performs a 7 digit match:

const TInt KNumberOfDigitsToMatch=7;
_LIT(KPhoneNumberToMatch,”020 75632000”);
CContactDatabase* database = CContactDatabase::OpenL();
CContactIdArray* results;
results = database>MatchPhoneNumberL(KPhoneNumberToMatch,KNumberOfDigitsToMatch);