Filter category with SimpleCursorAdapter Android
I am not sure why filtering is not working. I have seen many examples but
cursors are very particular.
I have a general list of items based on a database. Columns are _ID,
Category, Title and Content.
Under category there are two types: Note and To do.
So, I have 3 ListViews on my app, one for all items, one for notes,
another for todos.
In order to populate the notes list, I have this method:
private void fillNotesData() {
final ContentResolver resolver = getContentResolver();
final String[] projection = { Notero_Table.COLUMN_ID,
Notero_Table.NOTE_CATEGORY,
Notero_Table.NOTE_TITLE,
Notero_Table.NOTE_CONTENT };
final String mSelectionArgs = "%Note%";
mCursorForNotes = resolver.query(Notero_Provider.CONTENT_URI,
projection,
Notero_Table.NOTE_CATEGORY + " LIKE ?",
new String[] { mSelectionArgs },
null);
String[] from = new String[] { Notero_Table.NOTE_TITLE,
Notero_Table.NOTE_CONTENT };
int[] to = new int[] { R.id.text_row, R.id.text_row_two };
getLoaderManager().initLoader(0, null, this);
mAdapter = new SimpleCursorAdapter(this,
R.layout.row,
mCursorForNotes,
from,
to,
0);
setListAdapter(mAdapter);
}
The activity list is created, but there is no filter at all. There is
something wrong with the query for mCursorForNotes.
Any help?
Thanks.
No comments:
Post a Comment