同步数据库Mysql的SQLite的数据库、Mysql、SQLite

2023-09-05 23:46:13 作者:怀念或痛

可能重复:   how同步的android手机的SQLite数据库MySQL数据库服务器?

我想知道什么是对应用程序更新数据库的最佳方法。

I am wondering what is the best approach to updating a database on an Application.

我们有一个处理所有主要的服务器上的MySQL数据库,但我想复制这对我的应用程序。我想复制的数据库(MySQL的)在Android设备上,这样既熬夜到最新。这就不必是实时发生的,但每星期可以安排一次时,或者当作出更改SQL数据库。

We have a mysql database that handles everything on the main server, but I want to replicate this on my app. I would like to copy the database (mysql) on the android device so that both stay up-to-date. this would not have to happen in real time, but could be scheduled once every week, or when a change is made to the SQL database.

如何,我会做这样的事?

How would i do such a thing?

如要我送了这一点,作为更新的应用程序并创建更改数据库,或者我应该用得到数据库的服务器上,以改变一些方式,和SQLite的数据库跨到Android复制应用程序。

As in should I send this out as an update to the application and create the changed database, or should I use some way of getting the database to be changed on the server, and the SQLite data base be copied across to the android app.

还是......有没有这样做?一些不错的聪明的方式

Or ... is there some nice clever way of doing this??

谢谢 帕特

推荐答案

为什么不是你的服务器上使用时间戳(或版本字段)在MySQL数据库中,那么当Android应用程序时,它会暗示检查时间戳/版本看是否有变化,因为它需要更新。如果时间戳/版本比$ P $更新pviously中下载更新的其他数据集只需使用已存储。

Why not use a timestamp (or version field) in the mysql database on your server, then when the android app is run it imply checks the timestamp/version to see if there is a change since it needs to be updated. If the timestamp/version is newer than previously found download the updated dataset else simply use what is already stored.