I want to filter the inbox view of my app depending on the string entered in search view. So if user enters "How" the filter should get all the texts containing "How" in it this is the code I have written :
int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
AutoCompleteTextView textView = (AutoCompleteTextView) searchView.findViewById(id);
textView.setTextColor(Color.WHITE);
final Uri inboxURI = Uri.parse("content://sms/");
final String[] reqCols = new String[] {"_id","address","body" };
Cursor c = cr.query(inboxURI, reqCols, null, null, null);
final SimpleCursorAdapter sadapter = new SimpleCursorAdapter(this, R.layout.list_row, c, new String[] {"address", "body" }, new int[] {R.id.phone_number,R.id.text_msg});
textView.setAdapter(sadapter);
sadapter.setFilterQueryProvider(new FilterQueryProvider() {
public Cursor runQuery(CharSequence constraint) {
return getContentResolver().query(inboxURI, reqCols, "body" + " LIKE '" + constraint + "%'", null, null);
}
});
but here if I type "How" the filter returns only texts which start with "How". I want all the texts which contain this string at any position in it. Need help on how to create a query to get the result.
your query like constraint%
... change it like to like %constraint%
(note the additional %
)