Skip to content Skip to sidebar Skip to footer

Search Firebasedatabase For Users By Username

I am trying to search for users stored in my firebase database by username with a simple search bar (EditText) and when a button is clicked to display that particular user i have t

Solution 1:

According to your comments you are getting now all users. If you want to get only a single user, please change the following line of code:

Querysearchpeople= allUsersDatabase.orderByChild("username").startAt(seachbox)
                    .endAt(seachbox + "\uf8ff");

to

Querysearchpeople= allUsersDatabase.orderByChild("username").equalTo(seachbox);

Solution 2:

If you want make it easier, you can use Firestore instead of Realtime DB. But, if you want to still use RealtimeDB, you can create conditional loop like:

if(edtUsername.text.toString == username){
   // Your code
}

Post a Comment for "Search Firebasedatabase For Users By Username"