void AddRingtoneForContactL(const TDesC& aRingtone,TContactItemId aId)
{
CContactDatabase* ContactDb = CContactDatabase::OpenL();
CleanupStack::PushL(ContactDb);
CContactItem* SelItem = ContactDb->OpenContactL(aId);
CleanupStack::PushL(SelItem);
TInt RIndex = SelItem->CardFields().Find(KUidContactFieldRingTone);
if (RIndex != KErrNotFound)
{
SelItem->RemoveField(RIndex);
}
CContactItemField* contactField = CContactItemField::NewLC(KStorageTypeText,KUidContactFieldRingTone);
contactField->TextStorage()->SetTextL(aRingtone);
contactField->SetLabelL(_L("tone"));
contactField->SetMapping(KUidContactFieldVCardMapUnknown);
contactField->SetId(2);
SelItem->AddFieldL(*contactField);
CleanupStack::Pop();//ContactField
ContactDb->CommitContactL(*SelItem);
CleanupStack::PopAndDestroy(2);//ContactDb,SelItem
}
Tuesday, November 06, 2007
How to add a ring tone for a specific contact stored in contacts database.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment