
Originally Posted by
znrabbit
I use the commonframework.h as my head file, and fill my code into the doExampleL() .It crashes when it try to open the defualt database,and the emulator close down immediately.but before that ,everything is fine.The name of the database has print out.what is the problem?the database does not exist? what shall I do?
#include "commonframework.h"
#include <cntdef.h>
#include <cntdb.h>
#include <cntitem.h>
#include <cntfldst.h>
// do the example
LOCAL_C void doExampleL()
{
static CContactDatabase *cdb;
static CContactIdArray const *contacts;
CContactItem *item;
int i, n;
_LIT(KTxtcontact,"contactlist:\n");
TBuf<256> info(KTxtcontact);
console->Printf(KTxtcontact);
// Read name of the default database
TBuf<60> contactDBFile; //KOrgContactFile );
CContactDatabase::GetDefaultNameL( contactDBFile );
contactDBFile.LowerCase();
console->Printf(contactDBFile);
//Open default database
TRAPD(err, cdb= CContactDatabase::OpenL(contactDBFile));
CleanupStack::PushL(cdb);
//Check if database exists
if ( err == KErrNotFound )
{
_LIT(Error,"not exist");
console->Printf(Error);
}
else
{
_LIT(KTxtOK3,"ok3");
console->Printf(KTxtOK3);
}
CleanupStack::PopAndDestroy(cdb);
}