I want to implement a contact search with simplecursoradapter. And it should behave like standard android contact search. The problem is I can't write filter right. Now I have something like this:
private FilterQueryProvider filterQueryProvider = new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence Constraint) {
ContentResolver contentResolver = getActivity().getContentResolver();
Uri uri = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI,Uri.encode(Constraint.toString()));
String[] projection = { BaseColumns._ID, Phone.PHOTO_URI, Phone.DISPLAY_NAME, Phone.NUMBER, Phone.TYPE };
return contentResolver.query(
uri,
projection,
null,
null,
"upper(" + Phone.DISPLAY_NAME + ") ASC");
}
};
And it works, but there is a thing. When I put in filter a letter, 'm' for example, this filter gives me contacts which phones starts with '5'. So it "cast" letters to numbers. And I don't want this. What should I do?