Symbian3/SDK/Source/GUID-CF34D34E-FF17-5395-A1CD-768414E0B014.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?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-CF34D34E-FF17-5395-A1CD-768414E0B014"><title>Database Management</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The Contact Database is a database of Contact Items. The main API to the Contact Database is provided by the <xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita"><apiname>CContactDatabase</apiname></xref> class. The <xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita"><apiname>CContactDatabase</apiname></xref> class allows clients to create (<xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita#GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E/GUID-FB3A2CFA-21A0-3EE1-8267-30AB94720166"><apiname>CContactDatabase::CreateL()</apiname></xref>) a new Contact Database, or open (<xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita#GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E/GUID-5C43E2F0-BFC2-378A-8A1F-3641FF9DB764"><apiname>CContactDatabase::OpenL()</apiname></xref>) an existing one. </p> <p>Once opened, the database can be searched and sorted, and items within it can be edited or read, new items can be added and existing ones can be deleted (<xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita#GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E/GUID-5DE9AB9D-CD86-3EB1-9A91-68A1235BF162"><apiname>CContactDatabase::doDeleteContactL()</apiname></xref>). To edit an item, it must first be opened. Changes to the item can then be committed to storage using <xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita#GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E/GUID-35AD302C-659C-3705-961A-3730F2975B25"><apiname>CContactDatabase::CommitContactL()</apiname></xref>. Only open items can be committed. </p> <p>Client applications that need to be updated dynamically, as the database is altered by other clients, should derive from class <xref href="GUID-4928B1DE-9800-3887-B456-2DDFE810AFD9.dita"><apiname>MContactDbObserver</apiname></xref>. The observer's <xref href="GUID-4928B1DE-9800-3887-B456-2DDFE810AFD9.dita#GUID-4928B1DE-9800-3887-B456-2DDFE810AFD9/GUID-DECA9730-0504-3D4F-85D4-AFAC70B46580"><apiname>MContactDbObserver::HandleDatabaseEventL()</apiname></xref> function will be called in response to each change to the database. </p> <p>When contacts are modified the database can become fragmented, limiting the amount of space available. This leads to less efficient storage. To determine whether defragmentation is required for the database use <xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita#GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E/GUID-44EBA5DD-F790-30C2-AB22-AC6E3F2A1D3D"><apiname>CContactDatabase::CompressRequired()</apiname></xref>.This function provides an easy way of testing whether the database is being used efficiently. <xref href="GUID-781E8158-805B-3784-8FED-D7A191822FC3.dita"><apiname>ETrue</apiname></xref> is returned if a compression of the database is recommended. To compress the database to its minimum size use <xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita#GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E/GUID-ECF0D06A-E1E5-3285-994B-34D59BB588D8"><apiname>CContactDatabase::CompactL()</apiname></xref>. </p> <p> <xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita#GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E/GUID-BA8E31EE-0AE4-36E2-9AE4-88ADF63C85FE"><apiname>CContactDatabase::IsDamaged()</apiname></xref> tests to see whether the database is corrupted and needs to be recovered. If the database is corrupted it can be recovered through a rollback. <xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita#GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E/GUID-D14DFE6F-90E9-33DD-A108-10A23A8D5B53"><apiname>CContactDatabase::RecoverL()</apiname></xref> first closes all tables in the database and then reopens them after the database is repaired. <xref href="GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E.dita#GUID-6A6C7B3B-1E44-3731-956D-590A1122FF6E/GUID-5443434C-ADCD-348D-84EC-BBB40EF689EE"><apiname>CContactDatabase::DatabaseRollback()</apiname></xref> will force a rollback of the database. </p> </conbody></concept>