Categories: Code Examples | Symbian C++ | PIM | Files/Data | Audio
This page was last modified 13:43, 8 December 2007.
Setting contacts ringtone
From Forum Nokia Wiki
Following function shows how to add a ringtone for a specific contact stored in contacts database. aRingtone is the full name (with drive, path, name and extension) of the audio file to be set as a contacts ringtone and aId is the contacts ID of the contact for which the ringtone is set to.
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
}
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ringtone lengths | kid kia | General Discussion | 1 | 2008-03-02 11:34 |
| Joy RingTone Converter - Save any part of your mp3s to MMF, AMR, MIDI ringtone | mygods | News, Announcements and Job Listings | 0 | 2006-05-22 22:15 |
| How to Set Address Book Contact's Ringtone programmatically In J2ME | satyarajasekhar | Mobile Java General | 0 | 2008-04-30 12:45 |
| How to play ring tones on a game? | the_professor11 | Mobile Java Media (Graphics & Sounds) | 3 | 2004-02-18 15:55 |
| Nokia 3510 Ringtone Problem | ererciyes | Smart Messaging | 2 | 2002-08-20 11:49 |
