I'm developing an app and I want every user to have a unique username.
I have associated the unique username with user's UID like this:
mDatabase.child("users").child(user.getUid()).child("name").setValue(userName.getText().toString());
mDatabase.child("users").child(user.getUid()).child("uniqueUserName").setValue(uniqueUserName.getText().toString());
But how would I be able to know that the username which a new user has typed in is available or already taken?
Do I need to run a database search every time or is there some other better techniques?
Please let me know.