如何从Android的复制SQLite数据库MySQL数据库 - 复制 - 同步 [英] How Copy SQLite database from Android to a MySQL database - Replicate - Sync
问题描述
我建立一个Android应用程序,这将需要一些数据和图像的用户,并将它们存储在本地的SQLite数据库。我所期待的是一个途径,使我可以复制该数据库到MySQL数据库我的服务器上。
我看了网上的答案上,但没有一个妥善的解决办法吧。虽然我找到了最常见的答案是SymmetricDB并建立一个web服务。我仍然困惑采取哪条路线。
SQLite的数据库也可以在需要时,必须从MySQL数据库拉更新的数据,所以我想更好的词来使用的同步,而不是复制。
任何帮助吗?
是的,当然,它的同步
您必须创建 Web服务
为
只要遵循一些步骤从机器人将数据发送到MySQL :
- 创建使用你的数据
JSON
对象的JSONObject
和JSONArray
类。 - 后,作为一个字符串的
Web服务
,可能是在PHP
或你prefered - 工艺解析JSON和中
的MySQL
数据库中插入数据。
与从的MySQL到Android :
- 创建
Web服务
在JSON
格式显示数据。 - ,那么你有权要求该链接,你会得到JSON数据,只是你需要分析和存储到SQLite的。
您要照顾约数据Confiction。作为,你必须采取一个存储一些值两侧喜欢的上次同步日期/时间的。
有一些教程,这将有助于为Android JSON解析和 PHP JSON解析
。
如果有任何问题,那么你可以自由地ping通。
快乐同步。
感谢你。
I am building an Android app which will take some data and images from user and store them in a local SQLite DB. What i am looking forward to is a way by which i can replicate this DB to a MySQL DB on my server.
I looked on the Internet for the answer but there isn't a proper solution to it. Though the most common answers i found were SymmetricDB and Setting up a Webservice. I am still confused which route to take.
The SQLite DB may also at need, have to pull updated data from the MYSQL DB, so i guess the better word to use is Sync rather than Replicate.
Any help?
Yes of course, its Sync.
You have to create Web Service
for that.
Just follow some steps for sending data from Android to MySQL:
- Create
JSON
object of your data usingJSONObject
andJSONArray
class. - post that as an string to your
Web Service
that might be inPHP
or whatever you prefered. - process to parse json and insert data in to
MySQL
database.
Same as from MySQL to Android:
- Create
Web Service
that displays your data inJSON
Format. - then you have to Request to that link and you'll get JSON data, just you have to parse and store into SQLite.
You have to take care about Data Confiction. for that you have to take one that store some value both side like last sync date/time.
There are some tutorial that will help for android JSON Parsing and PHP JSON Parsing
.
If there is any problem then you can free to ping.
Happy Syncing.
Thank you.
这篇关于如何从Android的复制SQLite数据库MySQL数据库 - 复制 - 同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!