Synchronizing data between SQLite (Android) and MS-SQL (Hosting)

我们两清 提交于 2019-12-24 13:52:57

问题


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

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)

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).

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 ???

IMPORTANT

  • 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)

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


回答1:


Take a look at SyncAdapter: https://developer.android.com/training/sync-adapters/index.html

Synchronizing data between an Android device and web servers can make your application significantly more useful and compelling for your users. For example, transferring data to a web server makes a useful backup, and transferring data from a server makes it available to the user even when the device is offline. In some cases, users may find it easier to enter and edit their data in a web interface and then have that data available on their device, or they may want to collect data over time and then upload it to a central storage area.



来源:https://stackoverflow.com/questions/32615361/synchronizing-data-between-sqlite-android-and-ms-sql-hosting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!