mobile database backup/recovery on device
Anyone have working code to backup the local database on a device (specifically iPhone, but portability would be nice). I've tried several methods, but I can't get any of the .dump or .backup commands from sqlite to work.
The end result is an application that gets updates OTA and can revert to a previous version of the data if something goes wrong.
Thanks!
Eric
2 Answers
-
Accepted Answer
Eric,
Try closing the db & then use the Ti.Filesystem to create the backup, by reading the existing file and writing it out to the backup.
You should then be able to open the DB again.
-
db.execute('.backup dbBackup.db');
Error Domain=com.plausiblelabs.pldatabase Code=3 UserInfo=0x560d6a0 "An error occured parsing the provided SQL statement." (SQLite #1: near ".": syntax error) (query: '.backup dbBackup.db')