You Are Here:

Community: Wiki

This page was last modified on 31 March 2009, at 19:26.

How to compact local landmark databases

From Forum Nokia Wiki

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:

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fFileE3aMicrokernelE5fArchitectureE2eGIFX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ