You Are Here:

Community: Wiki

 

Talk:Reading and Editing a Contact Item

From Forum Nokia Wiki

There quite some mistakes in this article.

First:

// Open the default contacts database: CContactDatabase* contactsDb = CContactDatabase::OpenL(); CleanupStack::PushL(contactsDb);

// Get the ID of the own card and open the contact: TContactItemId ownCardId = contactsDb->OwnCardId(); CContactItem* ownCard = contactsDb->ReadContactL(ownCardId); CleanupStack::PushL(ownCard);

TInt count = ownCard->CardFields().Count(); contactsDb->CloseContactL(ownCard->Id()); CleanupStack::PopAndDestroy(); // ownCard


There has to be CleanupStack::PopAndDestroy(2); // ownCard, contactsDb since contactsDb is pushed on cleanup stack


Second error is here:

TContactItemId ownCardId = contactsDb->OwnCardId(); CContactItem* ownCard = contactsDb->ReadContactL(ownCardId);

Since there isn't all the time an own card id, this code should be

TContactItemId ownCardId = contactsDb->OwnCardId(); if(ownCradId != KNullContactId) {

   CContactItem* ownCard = contactsDb->ReadContactL(ownCardId);

}


For field indexing a check has to be made as well:

TInt index = ownCard->CardFields().Find(KUidContactFieldGivenName); ownCard->CardFields()[index].TextStorage()->SetTextL(KOtherForename);

Should be

TInt index = ownCard->CardFields().Find(KUidContactFieldGivenName); if(index != KErrNotfound) {

   ownCard->CardFields()[index].TextStorage()->SetTextL(KOtherForename);

}


Also I think article should mention how contact ids for other contacts than owncard can be obtained

--Pirosl 10:58, 15 September 2009 (UTC)


 
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: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fHttpE3aE2fE2f217E2e218E2e225E2e2E3a2082E2findeE78E2ehtmlE253FX 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