Namespaces
Variants
Actions

Delete a Contact Item

Jump to: navigation, search
Article Metadata

Article
Created: mayankkedia (06 May 2009)
Last edited: hamishwillee (20 Jul 2012)
Reviewer Approved    Thumbs up icon sm.jpg


The following example shows how to select a contact from the native contact database and delete it. This kind of behavior might be needed whenever you want to do something with the contact per se, without using the contacts application's delete option.

Header file required:

#include <CPbkContactEngine.h>
#include <CPbkSingleEntryFetchDlg.h>
#include <rpbkviewresourcefile.h>

CPbkSingleEntryFetchDlg & RPbkViewResourceFile link against library PbkView.lib , while CPbkContactEngine links against pbkeng.lib so add following line to your .mmp file.

LIBRARY PbkView.lib pbkeng.lib

Add following lines in .cpp file.

// load the contacts dialog resources
CCoeEnv* env = CEikonEnv::Static();
 
//Phonebook Engine for Phonebook Views
CPbkContactEngine* pbkContactEng = CPbkContactEngine::NewL( &env->FsSession());
CleanupStack::PushL(pbkContactEng);
 
RPbkViewResourceFile pbkRes(*env);
pbkRes.OpenL();
 
//Parameters for a Single Entry Dialog
CPbkSingleEntryFetchDlg::TParams params;
params.iPbkEngine = pbkContactEng;
params.iSelectedEntry = -1;
 
// Create and display a Single Entry Dialog
// params.iSelectedEntry will hold the selected Contact Id
CPbkSingleEntryFetchDlg* entryFetchDlg = CPbkSingleEntryFetchDlg::NewL(params);
entryFetchDlg->ExecuteLD(); //entryFetchDlg destroyed here
TContactItemId contactId = params.iSelectedEntry;
 
if(contactId != -1)
{
pbkContactEng->DeleteContactL(contactId); // if user selected a contact lets delete
}
 
pbkRes.Close();
CleanupStack::PopAndDestroy(); //pbkContactEng
CAPABILITY ReadDeviceData ReadUserData WriteDeviceData WriteUserData

Added by - Mayank on 06/05/2009

This page was last modified on 20 July 2012, at 09:21.
120 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved