How to develop an offline-first native Android app

Sangharsh picture Sangharsh · Sep 17, 2014 · Viewed 8.7k times · Source

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

  1. HTTPResponseCache: Cons: Caches only requests which have been hit once. Plus need different system to handle create/update actions.
  2. App42, Kinvey: Backend-as-a-service; Cons: We want to have own backend.
  3. Microsoft Sync Framework Toolkit: Not sure how well it works with Android
  4. PouchDB
  5. 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?

Answer

user3007919 picture user3007919 · Sep 18, 2014

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.