I have an issue with notifying CursorAdapter the Data been changed.
public class MyListFragment extends ListFragment implements LoaderCallbacks<Cursor> {
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return new MyListCursorLoader(getActivity());
}
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
MyCursorAdapter adapter = new MyCursorAdapter(getActivity(),(MyCursor)cursor);
setListAdapter(adapter);
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getLoaderManager().initLoader(0, null, this);
}
private static class MyCursorAdapter extends CursorAdapter {
... some code ...
}
private static class MyListCursorLoader extends SQLiteCursorLoader {
... code ...
}
SQLite database updates with AsyncTask (has public interface and ListFragment implements it with listener) and I try to refresh ListAdapter with onPostExecute, but I really don't know how.
AsyncTask code
public class MyDownloader extends AsyncTask<Void, Void, Void> {
public interface OnMyDownloaded {
void onMyDownloaded();
}
public JSONDownloader(Context context, OnMyDownloaded listener) {
...code...
}
protected Void doInBackground(Void... params) {
...code...
}
protected void onPostExecute(Void result) {
listener.onMyDownloaded();
}
Please, help me understand what should I do in MyListFragment inner class
private class OnEventDownloaded implements OnJSONDownloaded {
?????
}
You can call getLoaderManager().restartLoader(int id, Bundle args, LoaderCallbacks<D> callback);
It will call onCreateLoader, so loader will be recreated. If I understand you correctly.