iosdev1111
iosdev1111

Reputation: 1102

what is the best way to take the backup of data of sqlite3 database of iphone application?

i want to take the backup of all the data in the database of my iphone app in dropbox and restore it later.here the main problem is there is too much data in the app so if i am using sql queries to fetch data from sqlite3 database and storing it into the file and again reading data from that file and inserting it to database.can anyone suggest that how can i improve that or what is the best way to do that?

Upvotes: 0

Views: 892

Answers (4)

WINSergey
WINSergey

Reputation: 2005

my dropbox-based Sync API solution:

- (IBAction)onTouchDropboxBackup:(id)sender {

    DBAccount *account = [[DBAccountManager sharedManager] linkedAccount];

    if (account) {

        if (![sharedDelegate filesystem]) {

            DBFilesystem *filesystem = [[DBFilesystem alloc] initWithAccount:account];
            [DBFilesystem setSharedFilesystem:filesystem];
            [sharedDelegate setFilesystem:filesystem];
            [filesystem release];
        }

        DBPath *destination = [[DBPath root] childPath:kDataDBFileName];
        DBError *error = nil;

        //check presense
        DBFile *file = [[DBFilesystem sharedFilesystem] openFile:destination
                                                       error:&error];
        if (error){//not present

            [[DBFilesystem sharedFilesystem] createFile:destination
                                              error:&error];

            file = [[DBFilesystem sharedFilesystem] openFile:destination
                                                   error:&error];
        }

        if (!error) {

            [file writeContentsOfFile:[DOCUMENTS_DIR stringByAppendingPathComponent: kDataDBFileName]
                          shouldSteal:NO
                            error:&error];

            [file update:&error];
            [file close];
        }

    }else
        [[DBAccountManager sharedManager] linkFromController:self];
}

Upvotes: 0

Alexandre Ouicher
Alexandre Ouicher

Reputation: 856

You can use too a uuid as Key for your webservice. So, if the use delete app and when he reinstall, you cad download all data with key identifier.

For example:

uuid = [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier];

With Class for UUID

Important: Use the global mode because it allows to use the uuid between applications.

Upvotes: 0

Alexandre Ouicher
Alexandre Ouicher

Reputation: 856

You can use iCloud. Go to your app manager on Itunes Connect to generate a iCloud Key. So, all data will be stored on icloud.

Upvotes: 2

Eugene
Eugene

Reputation: 10045

I presume that you mean that you want to be able to restore the data after user has somehow deleted the application and re-installed it again. Since each application has its influence inside the bounds of its sandbox, the only sane option would be to use server. In regards to simply answering your question - there is no way to do it as you've described.

Upvotes: 2

Related Questions