hi there, i need help here ... i'm trying to get some of the details from the contact database in a phone such as name and phone num.Is there any available sample source code that i can have a look on it . by the way i did try to code myself by mixing my logic and other ppls source code that i get from this forum a.There is no copilation error but when i trigger the app in the emulor it just jump off returning an error. Can you guys have a look on my code .and tell me whats the problem......
// Set the windows size
SetRect(aRect);
iMsgIndex = 0;
// Create a control to display a list of messages
iListBox = new (ELeave) CAknSingleNumberStyleListBox;
iListBox->SetContainerWindowL(*this);
iListBox->ConstructL(this, 0);
iListBox->SetRect(aRect.Size());
iListBox->ActivateL();
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
iListBox->SetDimmed(ETrue);
// Create an array to hold the messages
iContactList = new (ELeave) CDesCArrayFlat(10);
//Open the contacts database
CContactDatabase* contactsDb = CContactDatabase::OpenL( );
CleanupStack::PushL( contactsDb );
static const TInt KMaxTIntLen = 4000;
HBufC* buffer = HBufC::NewLC(KMaxTIntLen) ;
const CContactIdArray* items = contactsDb->SortedItemsL();
//Search through the DB
for ( TInt i = 0 ; i < items->Count( ) ; i++ ){
const TContactItemId id = (*items)[i];
CContactItem* item = contactsDb->ReadContactL( id ) ;
CContactItemFieldSet& fields = item->CardFields() ;
CleanupStack::PopAndDestroy();
// Give it to the control
CTextListBoxModel* model = iListBox->Model();
model->SetItemTextArray(iContactList);
model->SetOwnershipType(ELbmOwnsItemArray); // transfer ownership of iMessageList
// Activate the window, which makes it ready to be drawn
ActivateL();
would help a lot if you could point out the line that is giving you the error. this you could get by putting a breakpoint into your code and running it line-by-line untill you get the error.
Also the error description shown in the screen would ease the problem solving process a lot. so in case you haven't got the error notes to show correctly, see this: http://www.newlc.com/article.php3?id_article=150