在SQLite(Android)和MS-SQL(托管)之间同步数据 [英] Synchronizing data between SQLite (Android) and MS-SQL (Hosting)

查看:115
本文介绍了在SQLite(Android)和MS-SQL(托管)之间同步数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在App SQLite数据库和在线托管的MS SQL数据库之间同步一些表.

I need to Synchronize some tables between the App SQLite Database an a MS SQL Database hosted online.

我已经在每个表上都有一个COLUMN(IsSync),可以让我知道哪些ROWS正在等待同步(即SELECT * FROM Locations where IsSync = 0)

I already have a COLUMN (IsSync) on each table that allows me to know which ROWS are pending sync (i.e. SELECT * FROM Locations WHERE IsSync=0)

位置表是表一旦更新/插入后就需要同步的表之一.该表包含每3-4秒(每分钟15条记录)插入的GPS位置数据(纬度,经度,精度,速度等).

The Locations table is one of the tables that I need to synchronize as soon as the table got updated/inserted. This table contains GPS Location data (Lat,Lng,Accuracy,Speed, etc) that is inserted EACH AND EVERY 3-4 SECONDS (15 records each minute).

由于我需要每N(2、3、4等)秒检查一次,因此需要同步多少行... 我应该在Activity中使用什么...一个计时器,一个服务, ???

Since I need to keep checking every N (2,3,4,etc) SECONDS how many rows need to be SYNC... what should I use inside my Activity... a TIMER, a SERVICE, a ???

重要

  • 我想要在此表上插入数据的过程APART,该过程检查必须更新多少行(通过JSON到HOST)

  • I want to have the process of INSERTING data on this table APART of the process that CHECKS how many rows must be UPDATED (via JSON to HOST)

该活动在我的Activity中必须是异步的,以免干扰在Activity中运行的任何其他任务/线程.

The process must be Asynchronous inside my Activity in order to not interfere with any other task/thread running inside the Activity.

推荐答案

看看SyncAdapter: https://developer.android.com/training/sync-adapters/index.html

在Android设备和Web服务器之间同步数据可以使您的应用程序更加有用并吸引用户.例如,将数据传输到Web服务器可进行有用的备份,而从服务器传输数据则即使用户处于脱机状态也可将其提供给用户.在某些情况下,用户可能会发现更容易在Web界面中输入和编辑数据,然后在设备上使用该数据,或者他们可能希望随着时间的推移收集数据,然后将其上传到中央存储区域.

这篇关于在SQLite(Android)和MS-SQL(托管)之间同步数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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