What you can do in this case is, order your database concerned child with Name
and compare them to the nameYouWant
, and using dataSnapshot.exists()
decide what you have to do with the user.
What I am saying, looks something like this in code:
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference().child("FacultyMember");
databaseReference.orderByChild("Name").equalTo(nameYouWant).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if(dataSnapshot.exists()){
for (DataSnapshot childSnapshot: dataSnapshot.getChildren()) {
String uid = childSnapshot.getKey();
}
else
// no such user exists
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) { // ToDo: Do something for errors too
}
});