Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Setting contacts ringtone

From Wiki
Jump to: navigation, search

Example code 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.

Article Metadata
Platform Security
Signing Required: DevCert
Capabilities: WriteDeviceData
Article
Created: symbianyucca (20 Mar 2007)
Last edited: hamishwillee (26 Jul 2013)

Headers:

#include <cntdb.h>
#include <cntitem.h>
#include <cntfldst.h>

Link against:

LIBRARY cntmodel.lib

Capabilities:

CAPABILITY WriteDeviceData
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
}
This page was last modified on 26 July 2013, at 23:29.
37 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×