1

I have created an app which contains a lot of data syncing between server and app. Now I want to adapt the tables and api from server to my phone's DB, so that data can be accessed via offline mode also.

There are 2 parts of my question:

  1. How will I port the tables from server MYSQL to phone's SQLite?
  2. I am having a lot of Api's to access specific data from server, how will implement those for fetching data from phone's SQLite?

Any help would be appreciated. Thanks in advance

MurugananthamS
  • 2,395
  • 4
  • 20
  • 49
  • Possible duplicate of [How to use an existing database with an Android application](http://stackoverflow.com/questions/9109438/how-to-use-an-existing-database-with-an-android-application) – Rafal Wiliński Aug 17 '16 at 06:52
  • Use API and local storage [ormlite](http://ormlite.com/) and for sync [observer pattern](https://andhradroid.wordpress.com/2012/04/05/object-observer-pattern-in-android/) – Lukáš Šálek Aug 17 '16 at 06:57

1 Answers1

0

Basically, you should move all method responsible for fetching data from server for a particular entity into separate interface. For you local database also create DAO ( data access object) interface and implement it. By doing so, you'll be able to write tests for you database and create implementations for different databases, ORMLite (or Realm)

Alex Shutov
  • 3,217
  • 2
  • 13
  • 11