Sync device data with web-server

大憨熊 提交于 2019-12-08 02:48:09

问题


I have data in my application which must be updated on the server on the basis of network availability. I store this data on a local database on android using sqlite. Currently the idea is:

  1. Data should be inserted on the local sqlite database
  2. A service should be waiting as soon as the data is inserted it checks the network availability and send it to the server and wait for success response.
  3. If the response true is received from the server it should update the sync status of that sqlite row and move to the next row to send the data.

I wanted to find out the best way to queue this data to send it to the server, additionally this queue should stop sending data to the server when the network is unavailable. Since there are lot of queues available in java which queu is the best to hold this data. Since the data can grow to any infinite size. It is a like a Producer-Consumer problem but what is the most efficient way to address it.

Thanks in advance.


回答1:


Why would you store this data in a queue when it is already stored in a local database? I mean what happens if your application is shut down then the data in the queue is lost. Just write a service that checks the local database for new entries. If there are new entries try to push them to the webserver.



来源:https://stackoverflow.com/questions/14952076/sync-device-data-with-web-server

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