×

Discussion Board

Results 1 to 2 of 2

Hybrid View

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    13

    CContactDatabase !!!! retrieving info from the contact database need help !!!!

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

    void CBubbleBasicAppView::ConstructL(const TRect& aRect)
    {

    CreateWindowL();

    // 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() ;

    for ( TInt j = 0 ; j < fields.Count() ; j++ ){
    const CContactItemField& field = fields[j];
    const CContentType& contentType = field.ContentType();
    TStorageType TType = field.StorageType( );
    if ( TType == KStorageTypeText && contentType.Mapping() == KUidContactFieldPhoneNumber ){
    CContactTextField* text = field.TextStorage();
    if( text->Text().Size( ) > 0 ){
    buffer->Des().Append('\t');
    buffer->Des().Append(text->Text() );
    iContactList->AppendL(*buffer);
    iListBox->HandleItemAdditionL();
    break;
    }
    }
    }

    }


    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();



    }

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169
    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

    yucca

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×