×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    113

    How to read phone numbers from phone book and seprate groups and phone numbers

    Hi,
    I am reading phone book from my S-60 V-2 device. The problem I am getting is when reading phone book I am getting both
    1. Phone numbers as well as
    2. Group names

    My requirement is to read only phone numbers and not the group that are in phone book.
    How can I do that....

    Your suggestions are appreciated.

    Thanks
    Jason

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: How to read phone numbers from phone book and seprate groups and phone numbers

    Hello,

    I have used CContactDatabase::ReadMinimalContactL() method. The list of TContactItemId items I get in advance by calling

    CContactDatabase::SetDbViewContactType(KUidContactCard);
    and
    CContactDatabase::SortByTypeL( sortPref );

    where sortPref are your sortign preferences.

    For groups ids I have used CContactDatabase::GetGroupIdListL() method.

    BR
    STeN

  3. #3
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    113

    Unhappy Re: How to read phone numbers from phone book and seprate groups and phone numbers

    Well I need to read all the phone numbers and not the group's but I need to read all the contact number that exists in the group.

    Overall I need to read all the phone numbers that is in phonebook.....


    Please help.....


    Thanks
    Jason

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: How to read phone numbers from phone book and seprate groups and phone numbers

    Quote Originally Posted by JasonSmithMiller View Post
    Well I need to read all the phone numbers and not the group's but I need to read all the contact number that exists in the group.

    Overall I need to read all the phone numbers that is in phonebook.....


    Please help.....


    Thanks
    Jason
    can you show us how you getting the numbers, that might help us to point where in code you require changes.

  5. #5
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    113

    Re: How to read phone numbers from phone book and seprate groups and phone numbers

    void CTextmtmviewAppUi::GetNumberFromCard(const TDesC &CardName, TDes &CardNum)
    {
    RPbkViewResourceFile phonebookResource( *(CEikonEnv::Static()));
    CPbkContactEngine* iPbkEngine = CPbkContactEngine::NewL();

    if ( !phonebookResource.IsOpen())
    {
    phonebookResource.OpenL();
    }

    // TContactItemId cardId;
    TBuf<25> buf_name(CardName);
    TInt nCount ;
    CContactDatabase* iContactDB = CContactDatabase::OpenL();
    CleanupStack::PushL(iContactDB);
    nCount = iContactDB->CountL();//

    CPbkContactItem* iContactItem;
    CPbkContactIter* iContactIter = CPbkContactIter::NewL(*iPbkEngine);
    TInt i = 0;
    for (TContactItemId cid = iContactIter->FirstL(); i < nCount; i++)
    {
    if (0 != i)
    cid = iContactIter->NextL();
    TBuf<30> toName;
    iContactItem = iPbkEngine->ReadContactLC(cid);

    TPbkContactItemField* lfield = iContactItem->FindField(EPbkFieldIdLastName);
    if (lfield)
    {
    toName.Append(lfield->TextStorage()->Text());
    }
    TPbkContactItemField* ffield = iContactItem->FindField(EPbkFieldIdFirstName);
    if(ffield)
    {
    if (lfield)
    toName.Append(' ');
    toName.Append(ffield->TextStorage()->Text());
    }

    if (toName == buf_name)
    {
    TPbkContactItemField* nfield = iContactItem->FindField(EPbkFieldIdPhoneNumberMobile);
    if(nfield)
    CardNum.Append(nfield->TextStorage()->Text());
    CleanupStack::PopAndDestroy(iContactItem);
    break;
    }
    CleanupStack::PopAndDestroy(iContactItem);
    }
    CleanupStack::PopAndDestroy(iContactDB);//
    // CleanupStack::PopAndDestroy(iPbkEngine);
    if(iPbkEngine)
    delete iPbkEngine;
    phonebookResource.Close();
    }

    This is the code I have written but the problem is that I am getting both phone numbers and groups both but what I want is to fetch only the phone numbers.

    Please suggest.....


    Thanks
    Jason
    Last edited by JasonSmithMiller; 2008-10-15 at 07:02.

  6. #6
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: How to read phone numbers from phone book and seprate groups and phone numbers

    try using CPbkContactIter instead and i did not understand why you used CContactDatabase and CPbkContactEngine both ?

  7. #7
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    113

    Re: How to read phone numbers from phone book and seprate groups and phone numbers

    Well thanks a lot for reverting. I have used this only to iterate but the program is working fine in emulator but not on series 60 V2 device.....


    Can you point out the problem............


    Thanks
    J

Posting Permissions

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