_LIT (KNameLabel, "Name"); _ LIT (kmobilelabel, "mobile"); _ lit (kname, "steve"); _ lit (kmobile, " 8613900000000");
// Open the default contacts database: CContactDatabase * contactsDb = CContactDatabase :: OpenL (); CleanupStack :: PushL (contactsDb); // Create a contact card and add some fields: CContactItem * contact = CContactCard :: NewLC (); CContactItemField * Field = ccontactItemfield :: Newlc (kstoRaGTypetext, kuidcontactfieldfamilyname);
Field-> setmapping (kuidcontactfieldvcardmapunusedn); Field-> setLabell (KNameLabel); Field-> TextStorage () -> setTextL (kname); Contact-> addfieldl (* field); cleanupstack :: Pop ();
field = CContactItemField :: NewLC (KStorageTypeText, KUidContactFieldPhoneNumber); field-> SetMapping (KUidContactFieldVCardMapTEL); field-> SetLabelL (KMobileLabel); field-> TextStorage () -> SetTextL (KMobile); contact-> AddFieldL (* field); Cleanupstack :: POP ();
// add the new contact to the database and set it as the w, contactsdb-> addnewcontact1; contactsdb-> setownloadcardl (* contact); Cleanupstack :: popandDestroy (2); // Contact ContactSDB