您需要将所有数据存储在数据库本地,然后检查互联网连接是否可用,如果互联网可用,请通过进行API调用将数据发送到Web,然后从本地数据库中删除数据从服务器接收响应。 这样从服务器获取响应后,删除你的本地数据库的每一行。
此实现,你可以有:
- create a database on mobile
- Register User on Server, After registering client should get a response from server and a timestamp.
- Save timestamp and register a Pending Intent for 12/24 hrs to Start a Background Service that would Sync the Data to Server.
- In case of no availability of Internet while Service wants to Sync data, we should have a Broadcast Receiver that check for internet connectivity, and as soon as Internet is available it would silently Start Service (Sync Service) in background and send data to Server.
- Server would again send a response with timestamp, on receiving timestamp we delete our local Database, and repeat step 3. This cycle will keep on repeating.
我想这应该服务器的目的。在如何实施这个留下评论。
来源
2012-07-28 19:38:44
Ali