Namespaces
Variants
Actions
Revision as of 05:39, 26 July 2012 by hamishwillee (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to compact local landmark databases

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:

130 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