Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 07:49, 16 April 2007.

Reading and Editing a Contact Item

From Forum Nokia Wiki


Whenever a contact item is opened for editing, it is locked to prevent simultaneous edits from other clients of the Contacts Model and it remains locked until it is either committed or closed. Therefore, unless you wish to edit a contact item, the item should be opened as read only with the CContactDatabase::ReadContactL() or ReadContactLC() function. The following code shows how to read information from a contact, in this case the own card contact:

// 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


The following code example shows how to open a contact for editing. The fields within a CContactItemFieldSet are indexed and the index of a particular field may be obtained by calling the CContactItemFieldSet::Find() function with the UID of the field that you are searching for. In the following example, the index that represents the forename field of the contact is obtained and this is subsequently used to modify the text in the field. Once editing the contact has been completed, the changes can be committed to the database by calling the CContactDatabase::CommitContactL() function. The CContactDatabase::CloseContactL() function closes the contact without saving the changes.

ownCard = contactsDb->OpenContactL(ownCardId);
CleanupStack::PushL(ownCard);
 
TInt index = ownCard->CardFields().Find(KUidContactFieldGivenName);
ownCard->CardFields()[index].TextStorage()->SetTextL(KOtherForename);
contactsDb->CommitContactL(*ownCard);
 
CleanupStack::PopAndDestroy(2); // ownCard contactsDb


Links

Adding a Contact Item

How to use contact database


--

Related Discussions
Thread Thread Starter Forum Replies Last Post
PIM contact list supported array elements gbaballa Mobile Java General 3 2008-07-09 13:40
mapping ccontactdatabase problem rajeshpadhiary General Symbian C++ 1 2008-08-13 15:19
Read and Write the encrypted data form file ankushbabrekar General Symbian C++ 6 2007-04-18 10:53
Symbian Contacts Plug-in jfenton Symbian Networking & Messaging 6 2007-08-08 15:13
Carbide.j on-device debugging SIGNED? pillar Mobile Java Tools & SDKs 4 2007-06-20 18:56
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX