Swas_99
Swas_99

Reputation: 2390

What is an acceptable approach to store data on mobile device that will be synced with the server when internet connectivity is available

When you use libraries like firebase/mixpanel they store data for some time if no internet connection is present and sync it with the server when internet is available. I was wondering what could be the best way to store offline data if I am creating a library/SDK with a similar feature for syncing data. What could the advantages/disadvantages of each approach?

I can think of using SQLite/SharedPreference/Realm to store the data temporarily but, if I am build an SDK, should I be using SQLite or Realm ?: as it is possible that the main application will be using one of these and creating multiple instances will have an impact on performance. But again, the data stored here will be temporary and, let's say, the amount of data that we need to store is also less.

Please guide me here by suggesting some proper approaches to do this and their respective pros & cons.

Also, it will be great to learn if anyone has any idea on how firebase/mixpanel does this.

Thanks in advance.

Upvotes: 0

Views: 60

Answers (1)

Manish Pratap Singh
Manish Pratap Singh

Reputation: 69

You can achiev thi by following steps :
1) The best approach use to SQlite to store ofline data .
2) Use ReactiveNetwork or Fast-Android-Networking to check internet availibility .
3) And on reciving network succes you can hit your API to sync offline data to server.

* you can set a boolean flag to false and make it true on sync success.by this you can check is there any data to sync to server is available offline.

Upvotes: 1

Related Questions