Archived:Updating contact's images in S60 3rd Edition FP2

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Tested with
Devices(s): Tested on Nokia N78
Platform(s): S60 3rd Edition, Feature Pack 2
S60 3rd Edition FP2
Created: User:Technical writer 1 (12 Aug 2008)
Last edited: lpvalente (18 Nov 2012)


When assigning an image to a contact on S60 3rd Edition, Feature 2 devices, both the thumbnail and the path to the full-size image must be updated.


Until S60 3rd Edition, Feature Pack 1 devices, only a thumbnail image could be assigned to a contact.

From S60 3rd Edition, Feature Pack 2 onwards, a contact also has an Image name field and an option to view the full-size image, via Image > View in contact details. When dialing a contact, a full-size image will be displayed on S60 3rd Edition, FP2 devices.

Therefore, to assign an image to a contact on S60 3rd Edition, FP2 devices, additional settings are required to update also the path to the full-size image.


Two functions are defined below. AssignPicture updates the thumbnail image for a particular contact. AssignPicturePath (needed from S60 3rd Edition, FP2 onwards) updates the path of the full-size image.

* void AssignPicture( HBufC8* aData, TContactItemId aId )
* Updates a specified contact item (aId) with thumbnail image data (aData)

void CContactContainer::AssignPicture (HBufC8* aData, TContactItemId aId)
CContactDatabase* contactsDb = CContactDatabase::OpenL();
CleanupStack::PushL( contactsDb );
CContactItem* contactItem = contactsDb->OpenContactL( aId );
CleanupStack::PushL( contactItem );
TInt index = contactItem->CardFields().Find( KUidContactFieldPicture );
if ( index != KErrNotFound )
contactItem->RemoveField( index );
CContactItemField* field;
field = CContactItemField::NewLC( KStorageTypeStore,
KUidContactFieldPicture );
field->SetMapping( KUidContactFieldVCardMapPHOTO );
field->AddFieldTypeL( KUidContactFieldVCardMapBMP );
// aData contains the thumbnails image data.
field->StoreStorage()->SetThingL( *aData );
contactItem->AddFieldL( *field );
CleanupStack::Pop( field );
// Save and close the contacts database
contactsDb->CommitContactL( *contactItem );
contactsDb->CloseContactL( aId );
CleanupStack::PopAndDestroy(2); // contactItem, contactsDb
* void AssignPicturePath( const TDesC& aImagePath, TContactItemId aId )
* Updates a specified contact item (aId) with a full-size image path
* (aImagePath)

void CContactContainer::AssignPicturePath( const TDesC& aImagePath,
TContactItemId aId )
// create pbkengine.
CPbkContactEngine* pbkContactEng =
CPbkContactEngine::NewL( &iCoeEnv->FsSession());
CleanupStack::PushL( pbkContactEng );
// Get image field info if there is no image assigned initially
const CPbkFieldsInfo& fieldsInfo = pbkContactEng->FieldsInfo();
CpbkFieldInfo* pbkFieldInfo = fieldsInfo.Find( EPbkFieldIdCodImageID );
// Open the contact item specified by aId
CPbkContactItem* aContactItem = pbkContactEng->OpenContactL( aId );
CleanupStack::PushL( aContactItem );
// Get the image field info
TPbkContactItemField* info = aContactItem->FindField( EPbkFieldIdCodImageID );
if ( !info )
// Add the image field if it was not found
TPbkContactItemField info = aContactItem->AddFieldL( *pbkFieldInfo );
if( KStorageTypeText == info.StorageType() )
// set path for the new image
CContactTextField* textstore = info.TextStorage();
textstore->SetTextL( aImagePath );
if( KStorageTypeText == info->StorageType() )
// Update with the new image path
CContactTextField* textstore = info->TextStorage();
textstore->SetTextL( aImagePath );
// Save and close the contacts database
pbkContactEng->CommitContactL( *aContactItem, EFalse );
pbkContactEng->CloseContactL( aId );
CleanupStack::PopAndDestroy( 2 ); // aContactItem, pbkContactEng
This page was last modified on 18 November 2012, at 01:00.
50 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.