Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to manage local landmark databases

From Wiki
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

This page was last modified on 7 February 2012, at 05:06.
48 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×