Symbian3/SDK/Source/GUID-58ACE248-BF26-57BB-B5D2-C772FC046222.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-58ACE248-BF26-57BB-B5D2-C772FC046222"><title>Searching the Contact Database</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The class <xref href="GUID-B9762BE2-1C1B-36CD-95EA-F7C4A832AA0B.dita"><apiname>CContactFindView</apiname></xref> provides a view of an existing <xref href="GUID-DA9AB241-DB29-3802-BF4F-195046341F78.dita"><apiname>CContactViewBase</apiname></xref> -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. </p> <p> <xref href="GUID-B9762BE2-1C1B-36CD-95EA-F7C4A832AA0B.dita#GUID-B9762BE2-1C1B-36CD-95EA-F7C4A832AA0B/GUID-B46629B1-4BF5-3A9A-BE2B-4E235B1AD816"><apiname>CContactFindView::FindL()</apiname></xref> 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. </p> <p>Email addresses are looked-up as follows: </p> <codeblock id="GUID-9D399274-604B-502B-95DC-A1AD3FCC15CD" xml:space="preserve">_LIT(KEmailAddressToLookup,”email@symbian.com”);
CContactDatabase* database = CContactDatabase::OpenL();
CContactTextDef* def=CContactTextDef::NewL();
def-&gt;Append(KUidContactFieldEMailValue);
CContactIdArray* results;
results=database-&gt;FindLC(KEmailAddressToLookup, def);</codeblock> <p> <xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita#GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E/GUID-756E0437-1589-3CA2-98FA-0412213B1DF4"><apiname>CContactDatabase::MatchPhoneNumberL()</apiname></xref> 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. </p> <p>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: </p> <codeblock id="GUID-F4D35B4D-CEE1-5F92-A04E-838B743A7FF8" xml:space="preserve">const TInt KNumberOfDigitsToMatch=7;
_LIT(KPhoneNumberToMatch,”020 75632000”);
CContactDatabase* database = CContactDatabase::OpenL();
CContactIdArray* results;
results = database&gt;MatchPhoneNumberL(KPhoneNumberToMatch,KNumberOfDigitsToMatch);</codeblock> </conbody></concept>