This tutorial describes how to access and modify the data in Central Repository at run time on the Symbian platform.
Repositories cannot be created at runtime. Applications must register with Central Repository using the initialisation file. The Central Repository API is provided by the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]CRepository
class. Applications access the repository with the UID of the repository. Applications must have appropriate access to the repositories.
Before you start, you must:
understand the Central Repository
know how to register and use the repositories in the Central Repository
Open a repository
The repositories are identified by a UID
. To access the data in the Central Repository create a new [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]CRepository
object with the UID
of the repository.
CRepository* repository = CRepository::NewL(KMyRepositoryUid);One [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]
CRepository
object must be created for each repository. Retrieve data from the repository
The data can be retrieved by using [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]Get()
or [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]Find()
functions of the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]CRepository
class.
Get()
to retrieve an individual value TInt Get(TUint32 aKey, TInt& aVal);
Find()
function to retrieve the values by passing a range of keys The input parameters are a partial key and a key mask and the function returns all the settings that match the input range. TInt FindL(TUint32 aPartialKey, TUint32 aKeyMask, RArray<TUint32>& aFoundKeys);
aKey
parameter represents a setting in a 32 bit unsigned integer and aVal
represents the corresponding value of the setting. Modify the data of the repository opened
The [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]Set()
functions of the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]CRepository
class allows the applications to modify the data in the Central Repository.
Set()
TInt Set(TUint32 aKey, TInt aVal);
GetMeta()
to get the metadata of the repository. The eight most significant bits are reserved for internal purpose and clients must not use these values. The value of the reserved bits may change for each [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]GetMeta()
call. GetMeta()
and the constant [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]KMetaUnreserved
to retrieve the user bits of the metadata. The constant KMetaUnreserved
is defined in centralrepository.h
. TInt GetMeta(TUint32 aKey, TUint32& aMeta);
Add a new setting
To add a new setting in the repository use [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]Create()
.
TInt Create(TUint32 aKey, TInt aVal);To delete an existing setting use [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]
Delete()
TInt Delete(TUint32 aKey);
Move settings
To move one or more settings from one key to another key use [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]Move()
TInt Move (TUint32 aSourcePartialKey, TUint32 aTargetPartialKey, TUint32 aMask, TUint32 &aErrorKey) ;The source key, target key and the partial mask must be provided by the clients.
Reset()
TInt Reset();
Reset()
function. TInt Reset(TUint32 aKey);Go back to step 2 if you want to modify the settings after a reset or continue to step 8
Close the repository
To close repository, use delete.
delete repository;Each instance of the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CRepository']]]
CRepository
object must be deleted to clean up the resources. The data in a repository will be modified with the new values by the application.