I am making an app which gets a time schedule from a website and display it in my app in a nice ListView. To make the schedule available when the user is offline I am trying to save it in a SQLite database first and get the data from there. The idea is that the database gets updated when the user starts the app, when the user presses a refresh button and at set times by a service running in the background.
My question is: how can I efficiently update and get data from the database without using the UI thread, thus not blocking user interaction.
I think I should use a system which puts tasks in a queue so that the database gets updated before the data gets displayed in my ListView. Other than this I don't have a single clue how to realise such a system on Android.
Ok so you need to implement three things:
1) Get data from website to db: for this you should use an AsyncTask
2) Make a ListView
that will get data from the db and update automatically. For this you will need to use a Loader which will handle the loading of the data on the background.
3) To use the loader you will need a ContentProvider
to provide you with the cursor needed and notify the ListView on changes.
For all three there are many nice tutorials online, for example see here