How to modify Contacts Database?
| Sat, 2003-12-20 14:57 | |
|
hi all,
I was just wondering whether it is possible to modify existing contacts/addressbook database that Symbian OS uses. e.g I want add a new field to store spouse's name or birthdate or any kind of data. Is it possible to add a new field in the existing database which contains default fields like phone number, Address info, etc. If this is possible then how should i do it? does anyone have any sample code available anywhere or any guidelines which I can follow? thanks in advance |
|






Forum posts: 148
ciao
Forum posts: 11
//Storing a contact to the database
// Some literal strings for the fields:
_LIT(KForenameLabel,"Forename");
_LIT(KSurnameLabel,"Surname");
_LIT(KWorkPhoneLabel,"Work Phone");
_LIT(KForename,"Steve");
_LIT(KOtherForename,"Bob");
_LIT(KSurname,"Wilkinson");
_LIT(KWorkPhone,"+441617779700");
// Open the default contacts database:
contactsDb = CContactDatabase::OpenL();
CleanupStack::PushL(contactsDb);
// Create a contact card and add some fields:
CContactItem* contact = CContactCard::NewLC();
CContactItemField* field = CContactItemField::NewLC(KStorageTypeText,
KUidContactFieldFamilyName);
field->SetMapping(KUidContactFieldVCardMapUnusedN);
field->SetLabelL(KSurnameLabel);
field->TextStorage()->SetTextL(KSurname);
contact->AddFieldL(*field);
CleanupStack::Pop();
field = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldGivenName);
field->SetMapping(KUidContactFieldVCardMapUnusedN);
field->SetLabelL(KForenameLabel);
field->TextStorage()->SetTextL(KForename);
contact->AddFieldL(*field);
CleanupStack::Pop();
field = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldPhoneNumber);
field->SetMapping(KUidContactFieldVCardMapTEL);
field->SetLabelL(KWorkPhoneLabel);
field->TextStorage()->SetTextL(KWorkPhone);
contact->AddFieldL(*field);
CleanupStack::Pop();
// Add the new contact to the database and set it as the own card:
contactsDb->AddNewContactL(*contact);
contactsDb->SetOwnCardL(*contact);
CleanupStack::PopAndDestroy(2); // contact contactsDb
Regards
---Rajesh
Work is the greatest thing on the earth.......
Thats why you should always leave some for tomorrow
Forum posts: 169
I used this code by when I want to Dial wiliam's number
my 3650 will be restart???
Forum posts: 36
Hello ,
I took u r code for Storing a contact to the database which u r writting here but there is problem for SetTextL.
It gives error "left of '->SetTextL' must point to class/struct/union ". and "use of undefined type 'CContactTextField'"
What should i do? Reply for this.
Forum posts: 37
field->TextStorage()->SetTextL(KSurname);
with
field->TextStorage().SetTextL(KSurname);
have fun...
Rayko Enz
www.sic-software.com
Forum posts: 36
I tried u r solution but again it doesn't work.gives same error "left of '.SetTextL' must have class/struct/union type".
Actually I want to add contacts into default fields of contact database.
(Is there any code for adding contacts from .txt file to contactDB.I used seperator ",".
If U have such a type of code pls. reply me.)
& thanx for reply.
Forum posts: 51
I tried u r solution but again it doesn't work.gives same error "left of '.SetTextL' must have class/struct/union type".
Actually I want to add contacts into default fields of contact database.
(Is there any code for adding contacts from .txt file to contactDB.I used seperator ",".
If U have such a type of code pls. reply me.)
& thanx for reply.
most probably ur first try was ok...only thing i think u forgot to include CNTFLDST.H