您需要將所有數據存儲在數據庫本地,然後檢查互聯網連接是否可用,如果互聯網可用,請通過進行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