I understand the requery()
mechanic, but i do not understand the implementation:
protected void onCreate(Bundle savedInstanceState) {
super.
the requery
cursor method is deprecated. but you're right you have to reload the cursor and then make sure that your new cursor is being presented to your ListView
. for a quick 'n dirty solution, I suggest you make your adapter a field. and then use the following method:
private void requery() {
Cursor values = datasource.getAllCategorie();
adapter.changeCursor(values);
}
What it does is remake a cursor. then by calling changeCursor
you swap the old cursor for the new one and the old one is closed automatically. at the very least, you save yourself from making a new adapter. The more sophicated approach with all the trim and fixes i suppose would be to implement a CursorLoader
which would perform the process automatically when the database content has been changed.