Discussion Board

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

    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;
    User::LeaveIfError(fileSession.Connect());
    CleanupClosePushL(fileSession);

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

    }

    CleanupClosePushL(file);

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



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

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

    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();
    filter->SetContactFilterTypeALL(EFalse);
    filter->SetContactFilterTypeCard(ETrue);
    contactsDb->FilterDatabaseL(*filter);

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

    i++;
    }


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

    //KVersitEntityUidVCard is used to identify a vCard
    TUid uid = TUid::Uid(KVersitEntityUidVCard);
    contactsDb->ExportSelectedContactsL(uid,
    *exportContacts,
    outputFileStream,
    //contact ID is no exported
    CContactDatabase::EExcludeUid);

    CleanupStack::PopAndDestroy(5); //exportContacts,contactsDb,
    //outputFileStream,file,fileSession


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

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

    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
    Code:
    TContactIter contactIterator(*contactsDb);
    TContactItemId contact_id;
    while( (contact_id = contactIterator.NextL() ) != KNullContactId)
    {
        exportContacts->AddL(contact_id); 
    }
    (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
  •  
×