战略与远程API同步Android应用程序数据库 [英] strategy for syncing Android app database with a remote API

查看:135
本文介绍了战略与远程API同步Android应用程序数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Android应用程序是一个客户端的远程web服务的JSON API(我建的服务器,所以我有最大的灵活性)。

I'm developing an Android app that is a client to a remote JSON webservice API (I built the server so I have maximum flexibility).

我试图决定什么是一个好的策略(在电池寿命,带宽方面和等待时间),以保持与远程API同步本地SQLite数据库。

I'm trying to decide what is a good strategy (in terms of battery life, bandwidth and wait times) to keep a local SQLite database synced with the remote API.

什么我目前的想法是,服务器将通过有关的任何行动GCM通知Android应用(或者应该是应该更新牵强或旧数据的新数据)
此外,用户将有一个刷新按钮手动进行同步。

what I'm currently thinking is that the server will notify the Android app via GCM about any action (either new data that should be fetched or old data that should be updated), also, the user will have a refresh button to manually do the sync.

这种方法的缺点是,如果GCM消息迷失有没有办法知道任何更新或新的数据。

cons of this approach is that if the GCM message is "lost" there is no way to know about any updates or new data.

我可以添加时间戳,并检查是否有新数据时,只要用户要求查看的东西,但是这并没有解决,以确定这就是已经在SQLite数据库时,旧的数据需要刷新的方式。

I can add timestamps and check for new data whenever the user asks to view something but this doesn't solve the way to determine when older data that's already in the SQLite database need to be refreshed.

改进本同步策略或任何其他方式我应该看看?有什么建议

any suggestions for improving this syncing strategy or any other approaches I should look into ?

推荐答案

您可以有应用程序发送接收的确认到服务器时,它得到了GCM推。然后,如果该服务器未看到的In x时限的确认,它可以重新发送GCM推

You could have the app send a received acknowledgement to the server when it gets the GCM push. Then, if the server doesn't see an acknowledgement in X timeframe, it could resend the GCM push.

这篇关于战略与远程API同步Android应用程序数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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