If you want to do something like giving special login access like usernames
and passwords
, you can use Firebase realtime database
to do so.
You can create a node named credentials
and then store every new username
and password
in it. Then to check if a person is logging in with correct details, you can search the database
records and match them with what the user is entering.
What I am saying, can be coded something like this:
DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("credentials");
//to store values in your credentials node just use this code
ref.child("usernames").child(username);
ref.child("usernames").child(username).child("password").setValue(password);
// here username and password are the strings you want to store
You can do this with all of your new users to register them in your app. Also this make it easier(read faster) for you to search for the particular username
and corresponding password
.
You can do so using the following piece of code:
ref.child("credentials").orderByChild("usernames").equalTo(username).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
// here you can do what you want, like comparing the password of the username and other things you require to do
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
4
solved How to login using username instead email on Firebase in Android application [duplicate]