Search code examples
androidsqlitermysqloffline-modetimetable

How to view data, that are parsed from the MySQL database, in offline, using SQLite?


I am developing my school's timetable app for android. I am getting timetable data from MySQL database. -> I have access to the timetable, only when I have an internet. But I want to make timetable accessible without the internet. I read that I need to save data from MySQL to the SQLite, and then use them. Can you, please, give me links to the samples how do to that?


Solution

  • I can point you in a direction that you might want to go in, you can try to use a ContentProvider to store and read data on your device offline. Once you create your ContentProvider, make use of your school's API through an AsyncTask (provided you have permission to access it) to format you some JSON to parse in Java with a library like Gson.

    Basically this relationship becomes like this:

    (Server)----JSON---->(AsyncTask)---->(Parse JSON in Client)---->(Move Parsed JSON data to your app's ContentProvider).

    There are numerous articles on things like this:

    ContentProvider example: https://developer.android.com/guide/topics/providers/content-provider-creating.html

    (Udacity also has free videos describing ContentProviders and JSON retrieval and parsing.)