Namespaces
Variants
Actions
Revision as of 08:06, 7 February 2012 by hamishwillee (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to manage local landmark databases

Jump to: navigation, search
Article Metadata

Article
Created: Den123 (10 Apr 2008)
Last edited: hamishwillee (07 Feb 2012)

All landmarks and categories are stored in databases, which may be local or remote. The primary identifier of the database is URI. The URI consists of a protocol specifier and the database location: "protocol://location".

For the local database:

  • protocol is "file".
  • location consists of disk drive and file name (with extension *.ldb)

Example of the local database URI: "file://C:my_data.ldb"

You can use Landmarks Database Management API for the database management. The main class of this API is CPosLmDatabaseManager. (include epos_cposlmdatabasemanager.h, link against eposlmdbmanlib.lib)

A couple of small examples:

The following code snippet demonstrates how to rename default landmark database:

_LIT( KNewName, "New Database Name" );
const TInt KMaxDbNameLen = 64;
TBuf<KMaxDbNameLen> newName( KNewName );
 
// Main DB Manager;
CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager :: NewL();
CleanupStack :: PushL( dbManager );
 
// Get default db URI
HBufC* defaultUri = dbManager->DefaultDatabaseUriLC();
if( defaultUri )
{
// Get db info by URI
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo :: NewLC( *defaultUri );
dbManager->GetDatabaseInfoL( *dbInfo );
 
// Get settings from info
TPosLmDatabaseSettings& settings = dbInfo->Settings();
 
// Set new name and save settings
settings.SetDatabaseName( newName );
dbManager->ModifyDatabaseSettingsL( *defaultUri, settings );
 
CleanupStack :: PopAndDestroy( 2 ); // dbInfo defaultUri
}
CleanupStack :: PopAndDestroy( 1 ); // dbManager


The following code snippet demonstrates how to copy all local databases from one drive to another:

// db manager;
CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager :: NewL();
CleanupStack :: PushL( dbManager );
 
// protocol for the local DB
_LIT( KFileProto, "file" );
 
// array, that contains URI of the local DBs
CDesCArray* dbUriList = dbManager->ListDatabasesLC( KFileProto );
 
const TInt KMaxUriLen = 128;
TBuf<KMaxUriLen> uri, newUri;
 
TChar driveFrom = 'C',
driveTo = 'E';
 
TBuf<1> newDrive;
newDrive.Append( driveTo );
 
for(TInt i = 0; i < dbUriList->Count(); i++ )
{
uri = (*dbUriList)[i];
if( uri[7] == driveFrom )
{
// setup new URI: file://C... -> file://E...
newUri = uri;
newUri.Replace( 7, 1, newDrive );
// check if such DB exists
if( dbManager->DatabaseExistsL( newUri ) )
{
// delete if already exists
dbManager->DeleteDatabaseL( newUri );
}
dbManager->CopyDatabaseL( uri, newUri );
}
}
 
CleanupStack :: PopAndDestroy( 2 ); // iDbList dbManager

Internal Links

82 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved