I am using FirebaseRecyclerAdapter in my firebase app and I am still till now didn't know how to search in Firebase by character, I have already used an query and I have got a good result but its not usable, here's my database I want to search in:
And here's my method that I use it but it get the "Username" if I enter full name only so if I write "m" nothing show:
mMainSearcher.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Query Q = mDatabase.child("Users").orderByChild("Username").equalTo(newText);
FirebaseRecyclerAdapter<Getting_Friends, Search.SearchViewHolder> firebaseRecyclerAdapter22 = new FirebaseRecyclerAdapter<Getting_Friends, Search.SearchViewHolder>(
Getting_Friends.class, R.layout.my_friends_card, Search.SearchViewHolder.class, Q) {
@Override
protected void populateViewHolder(final Search.SearchViewHolder viewHolder, final Getting_Friends model, int position) {
viewHolder.setUsername(model.getUsername());
viewHolder.setProfile(getApplicationContext(), model.getProfile());
}
};
mFriendsRecyclerView.setAdapter(firebaseRecyclerAdapter22);
return false;
}
});
Here's what I got when I enter fully name:
And here's what I got when I write "M" or "m":
So I only need >> When I write "m" automatically all users name start with "m" must be shown like mike.