At the moment I need to filter a Cursor/CursorAdapter to only show rows that match a specific condition in the ListView. I don’t want to requery the db all the time. I just want to filter the Cursor I got from querying the DB.
I have seen the question: Filter rows from Cursor so they don't show up in ListView
But I don’t understand how to do the filtering by overwritting the “move” methods in my CursorWrapper. An example would be nice.
Thank you very much.
UPDATE:
I have rewritten the source and my employer has made it available as open source software: https://github.com/clover/android-filteredcursor
You don’t need to override all the move methods in CursorWrapper, you do need to override a bunch though due to the design of the Cursor interface. Let’s pretend you want to filter out row #2 and #4 of a 7 row cursor, make a class that extends CursorWrapper and override these methods like so:
Now the interesting part is creating the filterMap, that’s up to you.