I want to develop a desktop application in Adobe Air with persisted local storage that will be catered by Adobe Air's SQLite. I want to implement row based synchronization and I've created the algorithm to do so (using timestamp field in the tables and comparing with lastsynced timestamp etc). I want this application to be accessible both offline and online. When Online, I want to sync the local db's newly edited row to online database (MySQL) but when application is being used in offline, i want to log all the edited rows and as soon as internet connection is restored, i want to sync all rows that were edited in offline mode to online DB. I am new to Adobe Air so can anyone guide that once we've stored the data in SQLite, how can we transmit/sync the desired rows to online DB? can anyone suggest me the libraries or APIs for that? also if i am using SQlite at client end and MySQL at server end, is it going to pose any problem? Please guide. thanks.
1 Answers
0
votes
In your local database add 3 flag fields is_created, is_updated, is_deleted which can have the value 0 or 1. For the rows that you get from the remote database set all 3 fields to 0.
When you edit a local row, set is_updated to 1. When you create a new local row, set is_created to 1. When you are online again, retrieve from your local database all rows that have is_created, is_updated or is_deleted flag set to 1, sync them with the remote database and then clear the flags from your local database.