Synchronize SQLite / Android database tables to remote MySQL database tables (via PHP)

I am trying to create a SQLite database when the program runs for the first time, which contains a table with 7 rows, which is designed to match the table on the MySQL database on the remote server. So my idea is:

(1) Create databases, tables, and rows with the required entries only the first time you run the application

(2) Poll a remote MySQL database (through PHP) on all runs (including the first one). The database contains a table with timestamp column. If the timestamp condition is met (that is, a new entry is placed in the database), all subsequent entries will be added to the SQLite database on Android phones

It would be great if someone could point me in the right direction or give me some basic code - thank you

resolvent:

Well, no magic bullet can synchronize android with the database in the cloud. Since you only process 7 rows, I will use asynctask and HTTP client to send get requests to your PHP page and return the 7 rows and time stamps as JSON documents. Then I will query your local SQLite database and get the rows and time stamps from it. Then, You can traverse 7 rows and update SQLite as needed. This is easy

If you want to use other databases, you may need to check CouchDB. They have an Android client (beta) that will synchronize with CouchDB in the cloud. You can create CouchDB on cloudant.com for free. If you want to use this method, go to Google "CouchDB Android"

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>