×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    8

    Error occur when using CPbkContactEngine::AddNewContactL

    the code as follow:
    ****************************************************************
    CPbkContactItem* newItem = iContactEngine->CreateEmptyContactL();
    CleanupStack::PushL(newItem);

    // Update personal information
    _LIT(KFirstName,"chao2");
    _LIT(KLastName,"Li");
    _LIT(KMobilePhone,"1348442051");

    TPbkContactItemField* field = newItem->FindField(EPbkFieldIdFirstName);
    field->TextStorage()->SetTextL(KFirstName);
    field = newItem->FindField(EPbkFieldIdLastName);
    field->TextStorage()->SetTextL(KLastName);
    field = newItem->FindField(EPbkFieldIdPhoneNumberMobile);
    field->TextStorage()->SetTextL(KMobilePhone);

    // add the new contact to the phone book.
    TRAPD(error, iContactEngine->AddNewContactL(*newItem));
    CleanupStack::PopAndDestroy(newItem);
    ****************************************************************
    error occur when using AddNewContactL, the error code is -23.

    Anyone give some help?
    thanks!

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,748

    Re: Error occur when using CPbkContactEngine::AddNewContactL

    Negative numbers are here: http://wiki.forum.nokia.com/index.php/Error_codes
    You may want to search for AddNewContactL in the Wiki.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    1,236

    Re: Error occur when using CPbkContactEngine::AddNewContactL

    I tried your code it seems working as it is intended to error code is 0. I didnt had any problems.
    Regards,
    Sriky

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    8

    Question Re: Error occur when using CPbkContactEngine::AddNewContactL

    Quote Originally Posted by wizard_hu_ View Post
    Negative numbers are here: http://wiki.forum.nokia.com/index.php/Error_codes
    You may want to search for AddNewContactL in the Wiki.
    i tried the method of Wiki's example,but the problem still on.the code as follow:
    *****************************************************************
    // Some literal strings for the fields:

    _LIT(KForenameLabel,"Forename");
    _LIT(KSurnameLabel,"Surname");
    _LIT(KWorkPhoneLabel,"Work Phone");
    _LIT(KForename,"Satya");
    _LIT(KOtherForename,"Naresh");
    _LIT(KSurname,"Vattikuti");
    _LIT(KWorkPhone,"+919985671193");

    // Open the default contacts database:
    CContactDatabase* contactsDb = CContactDatabase::OpenL();
    CleanupStack::PushL(contactsDb);

    // Create a contact card and add some fields:
    CContactItem* contact = CContactCard::NewLC();
    CContactItemField* field = CContactItemField::NewLC(KStorageTypeText,

    KUidContactFieldFamilyName);
    field->SetMapping(KUidContactFieldVCardMapUnusedN);
    field->SetLabelL(KSurnameLabel);
    field->TextStorage()->SetTextL(KSurname);
    contact->AddFieldL(*field);
    CleanupStack::Pop();


    field = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldGivenName);
    field->SetMapping(KUidContactFieldVCardMapUnusedN);
    field->SetLabelL(KForenameLabel);
    field->TextStorage()->SetTextL(KForename);
    contact->AddFieldL(*field);
    CleanupStack::Pop();

    field = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldPhoneNumber);
    field->SetMapping(KUidContactFieldVCardMapTEL);
    field->SetLabelL(KWorkPhoneLabel);
    field->TextStorage()->SetTextL(KWorkPhone);
    contact->AddFieldL(*field);
    CleanupStack::Pop();

    // Add the new contact to the database and set it as the own card:
    contactsDb->AddNewContactL(*contact);
    contactsDb->SetOwnCardL(*contact);

    CleanupStack::PopAndDestroy(2); // contact contactsDb
    *****************************************************************
    the code was running on emulator, sdk is 3.0.
    error is -23 KErrWrite, which means "During a file write operation, not all the data could be written."
    but i don't understand why this error happen.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    8

    Re: Error occur when using CPbkContactEngine::AddNewContactL

    Quote Originally Posted by sriky27 View Post
    I tried your code it seems working as it is intended to error code is 0. I didnt had any problems.
    thanks for your contribution:)

  6. #6
    Registered User
    Join Date
    Jun 2006
    Location
    India
    Posts
    1,043

    Re: Error occur when using CPbkContactEngine::AddNewContactL

    Hi,
    Have you checked with the capability of your application I guess you will need ReadUserData and WriteUserData to perform such operations.
    Maximus
    S60 Developer
    Impossible is nothing

  7. #7
    Registered User
    Join Date
    Aug 2006
    Posts
    8

    Re: Error occur when using CPbkContactEngine::AddNewContactL

    Quote Originally Posted by yogpan View Post
    Hi,
    Have you checked with the capability of your application I guess you will need ReadUserData and WriteUserData to perform such operations.
    yes,the problem disappeared by this way, thank you very much! :)

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,748

    Re: Error occur when using CPbkContactEngine::AddNewContactL

    Quote Originally Posted by gglaojiang View Post
    yes,the problem disappeared by this way, thank you very much! :)
    Just for completeness: such code can be executed in the emulator, and it has a logfile: http://wiki.forum.nokia.com/index.php/Epocwind.out
    The logfile contains warnings about missing capabilities, that way you could have found these two.

Posting Permissions

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