于Symbian OS的通讯录操作总结
2010-05-31 20:12:00 来源:WEB开发网TInt index =
ownCard->CardFields().Find(KUidContactFieldGivenName);
ownCard->CardFields()[index].TextStorage()
->SetTextL(KOtherForename);
contactsDb->CommitContactL(*ownCard);//提交所做的修改
CleanupStack::PopAndDestroy(2);
4、遍历数据库中的所有记录
CContactDatabase* contactsDb = CContactDatabase::OpenL();
CleanupStack::PushL(contactsDb);
TContactIter iter(*contactsDb);//建立遍历对象
TContactItemId cardId;
while( ( cardId = iter.NextL() ) != KNullContactId )
{
CContactItem* card = contactsDb->ReadContactL(cardId);
CleanupStack::PushL(card);
TInt nField =
card->CardFields().Find(KUidContactFieldGivenName);
TInt fField =
card->CardFields().Find(KUidContactFieldFamilyName);
if( nField!=KErrNotFound && fField!=KErrNotFound )
{ //读出数据
TPtrC name =
card->CardFields()[nField].TextStorage()->Text();
TPtrC fName =
card->CardFields()[fField].TextStorage()->Text();
iEikonEnv->InfoWinL(name, fName);
}
contactsDb->CloseContactL(card->Id());
CleanupStack::PopAndDestroy(); // card
}
CleanupStack::PopAndDestroy(); // contactsDb
5、过滤数据库中的记录
CContactDatabase* contactsDb = CContactDatabase::OpenL();
CleanupStack::PushL(contactsDb);
CCntFilter *filter = CCntFilter::NewLC();//建立过滤对象
filter->SetContactFilterTypeALL(EFalse);
filter->SetContactFilterTypeCard(ETrue);
_LIT(KFilterDate,"20040101:");
filter->SetFilterDateTime( TTime(KFilterDate) );
filter->SetIncludeModifiedContacts(ETrue);
contactsDb->FilterDatabaseL(*filter);
更多精彩
赞助商链接