This example application demonstrates the usage of Central Repository API for persistent storage.
Several Symbian platform components have state and settings information that need to be persistent. There is also a global state that needs to persist, for example, default filenames, locale settings, user preferences.
The CentRep example application first registers a group of settings with the central repository server. It uses E80000AD.txt, a UTF-16 format text file to initialise the repository. This text file contains access control structure and the initial content of the repository. It is recommended to convert the initialisation text file into a binary file using the central repository converter tool to speed up the execution.
The application creates a CRepository object using the CRepository::NewLC() method to access a repository using its UID. It resets the whole repository using CRepository::Reset() method with the contents in the initialisation file.
Each setting stored in the repository will have a unique key to identify the setting. This unique key is used to read and change the setting by calling the CRepository::Get() and CRepository::Set() methods respectively. The application moves these keys to a different location using CRepository::Move() method and deletes them from their original location.
The application also creates another CRepository object to demonstrate that, at any given point a repository cannot be opened with READ/WRITE access by more than one client. In such situations, it is recommended to start a transaction before a write operation using CRepository::StartTransaction() method. A transaction guarantees the consistency and persistence of all values read and written during the transaction.
Finally, the application requests the central repository server to notify any changes to the original settings.
Related APIs
CRepository - Provides access to a repository.
Click on the following link to download the example: CentRepExample.zip
Click: browse to view the example code.
The Symbian build process describes how to build an application.
The CentRepExample builds an executable called CentRepExample.exe in the standard location (\epoc32\release\winscw\<build_variant > for CodeWarrior). After launching the executable, depending on the emulator you are using, you may need to task away from the app launcher/shell screen to view the console.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.