I have a basic data-based application that uses Dropbox to back up and restore data. The backup method is quite simple. I copy the .sqlite file to the user's Dropbox.
Now my backup and restore functions work fine. The problem is with the .sqlite file itself. The .sqlite file seems to be incomplete .
I entered about 125 entries in my application and made a backup. The backup appeared in my Dropbox, but when I use the .sqlite explorer tool to view the contents, I only see records up to the 117th record.
I tried updating the first record, and then looked at the .sqlite file again, but there were no changes again.
What's even weirder is that the application seems to have recorded all the changes. When I add a new record or update an existing one and restart the application, the new data added seems to be saved. But this recently added data does not appear in my .sqlite file.
I support this code:
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; NSString *filePath = [[[appDelegate applicationDocumentsDirectory] path] stringByAppendingPathComponent:@"MyApp.sqlite"]; if (account) { if ([filesystem isShutDown]) { filesystem = [[DBFilesystem alloc] initWithAccount:account]; [DBFilesystem setSharedFilesystem:filesystem]; } DBPath *newPath = [[DBPath root] childPath:[NSString stringWithFormat:@"Backup - %@.sqlite", [NSDate date]]]; DBFile *file = [[DBFilesystem sharedFilesystem] createFile:newPath error:nil]; [file writeContentsOfFile:filePath shouldSteal:NO error:nil]; [filesystem shutDown]; }
I also copied the .sqlite file from the Simulator folder and tried to see it in the .sqlite browser. He still exhibits the same behavior. Any reason why this should happen?
database ios sqlite objective-c core-data
Gaurav wadhwani
source share