×
Namespaces

Variants
Actions

How to compact local landmark databases

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: Den123 (10 Apr 2008)
Last edited: hamishwillee (26 Jul 2012)

All local landmark databases are stored in files. As a result of some data changes ( for example: the addition of new landmarks ), it could happens that the size of database files will be greater then the necessary minimum.

The following code snippet demonstrates how to compress all local databases and calculate the count of the released bytes.

Headers Required:

#include <epos_cposlmdatabasemanager.h>
#include <epos_cposlandmarkdatabase.h>
#include <aknnotewrappers.h> //for the information note

Link against:

LIBRARY eposlmdbmanlib.lib'' 
LIBRARY eposlandmarks.lib''
LIBRARY avkon.lib eikcdlg.lib eikctl.lib //for the information note

Source:

// 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 );
 
TInt delta = 0; // delta of the total size
for(TInt i = 0; i < dbUriList->Count(); i++ )
{
// open database
CPosLandmarkDatabase* db = CPosLandmarkDatabase :: OpenL( (*dbUriList)[i] );
CleanupStack :: PushL( db );
 
// initialize if necessary
if( db->IsInitializingNeeded() )
ExecuteAndDeleteLD( db->InitializeL() );
 
// get size before compact
CPosLandmarkDatabase :: TSize oldSize = db->SizeL();
 
// execute compact in batch mode
ExecuteAndDeleteLD( db->CompactL() );
 
// get size after compact
CPosLandmarkDatabase :: TSize newSize = db->SizeL();
 
// inc delta
delta += oldSize.iFileSize - newSize.iFileSize;
CleanupStack :: PopAndDestroy(); // db
}
CleanupStack :: PopAndDestroy( 2 ); // iDbList dbManager
 
// create message
_LIT( KMess, "Released bytes: " );
TBuf<32> mess( KMess );
mess.AppendNum( delta );
 
// show message
CAknInformationNote* informationNote;
informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( mess );


Related Links:

This page was last modified on 26 July 2012, at 05:39.
37 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.

×