I'm creating an android app where I store some objectives in an sqlite database. Also I'm fetching that content from the online mysql database if there's new content.
So when the main activity launches it loads the stored data from the sqlite db in a list view en then does a JsonObjectRequest with Volley. (An Async Task)
But still I'm getting the following errors when launching the main activity
Skipped 88 frames! The application may be doing too much work on its main thread.
Skipped 34 frames! The application may be doing too much work on its main thread.
The 88 frames is from the sqlite database, loading all the stored data. Because when I swipe down to refresh I only do the JsonObjectRequest en get the error with like 34 frames.
Do I maybe have to put the sqlite db loading also in an AsyncTask? Or do you have another solution?
I'd love to hear you opinion. Thanks in advance.
Wiljan
EDIT:
I now put it in an Async like this:
private class syncData extends AsyncTask<Void, Void, Void> {
private KerntaakListAdapter adapter;
public syncData(KerntaakListAdapter adapter) {
this.adapter = adapter;
}
/**
* The system calls this to perform work in a worker thread and
* delivers it the parameters given to AsyncTask.execute()
*/
@Override
protected Void doInBackground(Void... params) {
dataSource.syncData(swipeRefreshLayout);
return null;
}
/**
* The system calls this to perform work in the UI thread and delivers
* the result from doInBackground()
*/
protected void onPostExecute(String result) {
adapter.notifyDataSetChanged();
}
}
And trigger it with this:
new syncData(adapter).execute();
But it still gives me an skipped frames error. Although the frames are a bit reduced..