I am facing the issue in search view top search the data in realm database.I have implemented the search view and problem is how to pass the search query to the realm database to search data.
My search view implementation is
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
//*** setOnQueryTextFocusChangeListener ***
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
}
});
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String searchQuery) {
RealmDbHelper realmDbHelper = new RealmDbHelper();
return true;
}
});
I have idea but i am little confused to implement that
RealmResults<RealmPhoneCallLogs> allQueryData = realm.where(RealmPhoneCallLogs.class)
.like("number","?790*", Case.INSENSITIVE).findAll().sort("id",Sort.DESCENDING);
The above method is used to implement the searchview to search but i don't know how to pass the argument to LIKE Wildcard query.
Please help me how to query the searchview data.