Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Aug 2014

    Post [moved] How to take backup of all contacts in a single file

    Hi, all
    I have been trying to get contacts backup for N85

    am using sdk S60 v3 API,Carbide IDE

    here is the code snnipet

    _LIT( KDbTestFileName, "e:\\file.txt" );

    RFs fileSession;
    RFile file;

    if (file.Replace(fileSession, KDbTestFileName, EFileWrite) != KErrNone)
    //failed to create the file
    CleanupStack::PopAndDestroy(); //fileSession



    //open a write stream to the file
    RFileWriteStream outputFileStream(file);

    //open the default contacts database
    CContactDatabase* contactsDb = CContactDatabase::OpenL();

    //create an array of contact IDs to export
    CContactIdArray* exportContacts = CContactIdArray::NewL();

    TContactIter* contactIterator = new (ELeave) TContactIter(*contactsDb);
    TContactItemId contact_id;

    //use a filter to get only contact items (e.g. templates are excluded)
    CCntFilter *filter = CCntFilter::NewLC();

    //create an array to hold all filtered contact items
    CContactIdArray* contactIds;
    contactIds = CContactIdArray::NewLC();

    int i = 0;

    while( (contact_id = contactIterator->NextL() ) != KNullContactId)

    //add given contact(by index) to the array of contact IDs to export
    if((*contactIds).Count() >= i)
    exportContacts->AddL((*contactIds)[i] );


    CleanupStack::PopAndDestroy(2); //contactIds, filter

    //KVersitEntityUidVCard is used to identify a vCard
    TUid uid = TUid::Uid(KVersitEntityUidVCard);
    //contact ID is no exported

    CleanupStack::PopAndDestroy(5); //exportContacts,contactsDb,

    does ExportSelectedContactsL will export only single contact or all the all contatct

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Oslo, Norway

    Re: [moved] How to take backup of all contacts in a single file

    Quote Originally Posted by vignesh_silvanlabs View Post
    does ExportSelectedContactsL will export only single contact or all the all contatct
    The second argument (CContactIdArray, "exportContacts" in your code) specifies what to export. If it contains a single ID, that item will be exported. If it contains all ID-s, all items will be exported.
    I am not sure if exportContacts will really contain anything in this code, as the while-loop with the iterator actually does not use the iterated ID-s. The filter is not used at all.
    Try something like
    TContactIter contactIterator(*contactsDb);
    TContactItemId contact_id;
    while( (contact_id = contactIterator.NextL() ) != KNullContactId)
    (I guess you do not really want to learn Symbian C++ right now, just the short story is that T-types are value types, so there is no need to put them on the heap)

Similar Threads

  1. NBF file corrupted? "no backup file available" when recovering backup file (7210c)
    By emmeemmeuno in forum General Development Questions
    Replies: 3
    Last Post: 2011-03-01, 12:43
  2. Can't Restore my .arc contacts backup file
    By jadjoubran in forum General Development Questions
    Replies: 1
    Last Post: 2009-12-29, 11:45
  3. [moved] Single SISX file with multiple applications embedded in it
    By thokkal in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 3
    Last Post: 2009-02-23, 19:58
  4. N73 backup problem; how to restore to device from backup file
    By dandekar.abhay in forum General Development Questions
    Replies: 4
    Last Post: 2008-04-30, 16:31
  5. PC Suite 4.5 - backup contacts into a CSV file, outlook or other.
    By Briano in forum General Development Questions
    Replies: 2
    Last Post: 2008-02-06, 07:08

Posting Permissions

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