I am developing a registration system using Firebase. I used the registration method with email and password. When a user registers he is registered as an account with the email and password, in addition all the data entered by him except the password (email, image link and username) will constitute a hereditary structure in the DB firebase realtime (the id which is assigned to the user will be the parent) in this way:
However, I must verify if the user enters an existing username. The problem is that I should go check on all the children and check if the value of them is equal to the username entered and, I do not know how to do this.
example of the value of children to be verified:
Can anyone suggest me a way to do this?
Code updated:
FirebaseDatabase.getInstance().getReference("Usernames").child(us.getText().toString()).setValue("Saved").addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful())
Toast.makeText(getApplicationContext(), "Il nome non esiste",Toast.LENGTH_SHORT).show();
else
Toast.makeText(getApplicationContext(), "Il nome esiste",Toast.LENGTH_SHORT).show();
}
});