Replication between Mysql and Sqlite (E vice versa)

Asked

Viewed 1,756 times

3

I am developing a system that integrates a Mysql database with an Android application (through a webservice). I can already make connection, pass data, change them in the database through the App and things like that.

My problem is the moment I need to replicate between the bases.

Example: If I have already uploaded a list in the app with the name and number of a customer and need to change the number there in the bank, this change does not come to the app. Unless I recreate the bank in the app. (I hope I’m making myself clear).

I searched but found nothing useful, I just wanted a hint of how to do, if someone has done something similar, simply the 'best way' to solve it.

  • You can help: http://answall.com/a/44549/6077

  • Would your problem be that the changes in your remote bank are not replicating in your app or the other way around? That wasn’t very clear.

  • You do not need to recreate the database on android to update data. Data need to get to Android somehow. It can be a txt with Inserts, or a . sqlite file for reading and processing. Here we use manual import routines. We use Asynctask to download the data, via FTP, or HTTP. Using Sqlitestatements for bank operations, picking up the cursor from the received file and updating at the base of the APP.

2 answers

1

Implementing this kind of thing is never simple. A first suggestion is to put a timestamp on each line, so that you have how to know the "version" of each line, there you have a basis to compare if the line in the local Sqlite is obsolete compared to the database and vice versa.

If you store somewhere when it was the time of the last synchronization of each cell phone, you can even make a SELECT filtering by timestamp (equal or greater than the last synchronization) and you easily pick the altered lines, and made it easy to support multiple phones syncing at the same time.

A more annoying problem is the issue of removing lines. If the (s) table(s) involved(s) never removes(m) lines, ok. If they remove, you need to log (register) these removals somewhere, with timestamp, so that they are part of the update received by mobile.

0

There is no way to replicate directly.

You need to create a Webservice/API to communicate.

This is a little complex because you need to be careful with the version control of the data.

There is a commercial framework that proposes to simplify this work: http://sqlite-sync.com/

Also offers free version, with limitations on access to source code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.