If you are using a CursorLoader
then you should store the search query in a member variable for later use, instead of using the adapter's filter:
say,
private String mSearchQuery;
and then change the loader creation to work with the search query
@Override
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
showProgress(true);
if (TextUtils.isEmpty(mSearchQuery)) {
return new CursorLoader(
mActivity,
CONTENT_URI,
PROJECTION,
DEFAULT_SELECTION,
null,
SORT_ORDER
);
}
mSearchQuery = "%" + mSearchQuery + "%";
return new CursorLoader(
mActivity,
CONTENT_URI,
PROJECTION,
// add the filtering criteria to the default.
DEFAULT_SELECTION + " AND " + COLUMN_A + " LIKE ?",
new String[]{mSearchQuery},
SORT_ORDER
);
}
and finally, make sure that you reload the loader
@Override
public boolean onQueryTextChange(String newText) {
mSearchQuery = newText;
// calls the above method
mActivity.getSupportLoaderManager().
restartLoader(0, null, this);
return true;
}