问题
We are developing a native Android app (iOS and web to follow) where users can collaboratively create an album.
We want as seamless as possible experience when device is not able to connect with server. Something like mentioned in this Hoodie blog but Hoodie is right now for Web and iOS and we are looking for Android right now.
Problem
Maintaining data of albums, friends, pictures (URL/local, not Bitmap) on Client side. Being able to sync offline create/update operations to server at later time, with conflict resolution.
Current research
- HTTPResponseCache: Cons: Caches only requests which have been hit once. Plus need different system to handle create/update actions.
- App42, Kinvey: Backend-as-a-service; Cons: We want to have own backend.
- Microsoft Sync Framework Toolkit: Not sure how well it works with Android
- PouchDB
- Superbus: Solves a part of the problem
Custom
Maintain data in SQLite on Android and MySQL on server Sync using Android Sync Adapter. However, this can be time consuming and have bugs in starting.
How should this problem be approached?
回答1:
I am working on a project at the moment, and we need to track deliveries and verify deliveries even when user is offline. The approach I use is to make use of this ContentProvider plugin Simple Content Provider. And I check if there's internet or not, and if there's none. It stores the data to the provider and change whatever needs to be changed in the DATABASE and make my user believe he or she has completed the order. And I've a SyncAdapter waiting for the internet to come on. And, I've a push service too to refresh the database once there's a change in the database. Having an understanding of Google Cloud Messaging would save your user a lot of battery life. There might be better options out there. But, from my little experience with Android that's how my little help could be.
回答2:
Did you had a look in CouchBase Server and CouchBase Lite?
They provide a powerfull tool called the SyncGateway wich handle for you all the syncronisation and the merging of the datas between the server and the internal database. You don't have to code anything in your mobile App for the synchonisation.
Couchbase Lite is availbe for iOS and Android. There is also a plugin for Cordova/PhoneGap available.
I never had any problem to compile it, just for iOS keep in mind to compile for iOS6+, it does not work with iOS5
回答3:
You can check out an open source api for this called Wendy the most amazing thing about it is that it uses your existing architecture.
来源:https://stackoverflow.com/questions/25887118/how-to-develop-an-offline-first-native-android-app