Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 27
Registered: ‎08-14-2012
My Device: bold9780

Problems about change/delete contacts photo

Dear all,

    I am working on a project about change contacts photo. I have solved add photo to a contact without photo by using setoriginalphoto(); and setprimaryphoto(); However when I trying to set a new photo tu a contact with photo already, I can not find some api or function to do that.

    I want to delete photo first and add to it than, but the function updatecontacts(); is always uses a lot of time(about 3-4 sec one contact). So I do not konw how to do with it.

    If any one know or do the same thing, pls help me.

    Thank you all.


 * ContactsDetail.cpp
 *  Created on: 2013-8-22
 *      Author: user

#include "ContactsDetail.hpp"

#include <iostream>

#include <QObject>
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <bb/cascades/LocaleHandler>
#include <bb/cascades/Page>
#include <bb/cascades/Label>
#include <bb/data/XmlDataAccess>
#include <bb/cascades/GroupDataModel>
#include <QFile>
#include <bb/cascades/ListView>
#include <bb/cascades/ImageView>
#include <QString>
#include <QXmlStreamReader>
#include <QTextCodec>
#include <bb/cascades/ArrayDataModel>
#include <bb/cascades/XmlDataModel>
#include <bb/pim/contacts/ContactListFilters>
#include <bb/pim/contacts/ContactService>
#include <bb/pim/contacts/ContactBuilder>
#include <bb/pim/contacts/ContactPhotoBuilder>
#include <bb/pim/contacts/ContactPhoto>

using namespace bb::cascades;
using namespace bb::pim::contacts;
using namespace std;

		: contactService(new ContactService(this))
	qDebug()<<"ContactsDetail cpp OK";
	largephotoimage = NULL;
void ContactsDetail::init(QString contact_Id,QObject* imageview)
	largephotoimage = dynamic_cast<ImageView *>(imageview);
	bool ok;
	Contact contactDetails = contactService->contactDetails(contact_Id.toInt(&ok,0));
	ContactBuilder editor = contactDetails.edit();
	ContactPhoto photo;
	for(int i = 0 ; i < contactDetails.photos().length() ; )
		photo = contactDetails.photos().at(i);
		qDebug()<<"photo list file path : "<<photo.largePhoto();
		editor = editor.deletePhoto(photo);
	contactService->updateContact(editor.operator bb::pim::contacts::Contact());
	contactDetails = contactService->contactDetails(contact_Id.toInt(&ok,0));
	photo = contactDetails.primaryPhoto();
	largephotoimage->setImageSource(QUrl (photo.originalPhoto()));


Posts: 27
Registered: ‎08-14-2012
My Device: bold9780

Re: Problems about change/delete contacts photo

is any one know about this?