如何从Android的复制SQLite数据库MySQL数据库 - 复制 - 同步 [英] How Copy SQLite database from Android to a MySQL database - Replicate - Sync

查看:314
本文介绍了如何从Android的复制SQLite数据库MySQL数据库 - 复制 - 同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个Android应用程序,这将需要一些数据和图像的用户,并将它们存储在本地的SQLite数据库。我所期待的是一个途径,使我可以复制该数据库到MySQL数据库我的服务器上。

我看了网上的答案上,但没有一个妥善的解决办法吧。虽然我找到了最常见的答案是SymmetricDB并建立一个web服务。我仍然困惑采取哪条路线。

SQLite的数据库也可以在需要时,必须从MySQL数据库拉更新的数据,所以我想更好的词来使用的同步,而不是复制。

任何帮助吗?

解决方案

是的,当然,它的同步

您必须创建 Web服务

只要遵循一些步骤从机器人将数据发送到MySQL

  1. 创建使用你的数据 JSON 对象的JSONObject JSONArray 类。
  2. 后,作为一个字符串的 Web服务,可能是在 PHP 或你prefered
  3. 工艺解析JSON和中的MySQL 数据库中插入数据。

与从的MySQL到Android

  1. 创建 Web服务 JSON 格式显示数据。
  2. ,那么你有权要求该链接,你会得到JSON数据,只是你需要分析和存储到SQLite的。

您要照顾约数据Confiction。作为,你必须采取一个存储一些值两侧喜欢的上次同步日期/时间的。

有一些教程,这将有助于为Android JSON解析和 PHP JSON解析

  1. 为Android
  2. 对于PHP

如果有任何问题,那么你可以自由地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:

  1. Create JSON object of your data using JSONObject and JSONArray class.
  2. post that as an string to your Web Service that might be in PHP or whatever you prefered.
  3. process to parse json and insert data in to MySQL database.

Same as from MySQL to Android:

  1. Create Web Service that displays your data in JSON Format.
  2. 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.

  1. For Android
  2. For PHP

If there is any problem then you can free to ping.

Happy Syncing.

Thank you.

这篇关于如何从Android的复制SQLite数据库MySQL数据库 - 复制 - 同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆