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 );
No related wiki articles found