This might be a noob question but I'm quite new to all this SQLite-Database-Cursor-Adapter-ListView-Do-It-Properly-Stuff.

What I have:

In my MainActivity I have a ListView. I use an SQLite database and populate the ListView with a custom adapter extending SimpleCursorAdapter. By clicking on an item in my ActionBar I activate Contextual Action Mode. Everything is working so far.

What I want:

By clicking on a certain icon in my ListView item the according database row should be deleted and the ListView should be refreshed.

My question:

How do I refresh my Cursor and my ListView properly? When I don't use cursor.requery() in my OnClickListener and use cursor = dbm.getIOIOSensorsCursor() instead I get a CursorIndexOutOfBoundsException a few rows below at the line

int state = cursor.getInt(cursor.getColumnIndex(IOIOSensorSchema.STATE));

My app crashes, but after reloading it the database has been deleted and the according ListView item is gone.

I guess the crash must have something to do with _position in get getView method because _position is final. However, when I use cursor.requery() everything works as it should.

But this method is deprecated and it's documentation says "Don't use this...". I'm a friend of coding properly (I'm still a beginner and want to learn to code the right way and not quick-and-dirty) and want to know how to do this right. I don't know if it's important but I'm testing my app only on my (really fast) Nexus 4. There seem to be no problems with refreshing the Cursor fast enough, but I wonder if it will wo

Edit
Report