I wanted to compare the user's email who signed in to my app with already registered user's email from my firebase database.
How can I get the value of
emailFromDatabase
values outside theonDataChange
method so that I could compare the database's email value to my signed in user's email?
usersListDatabaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot emailSnapshot: dataSnapshot.getChildren()) {
String emailFromDatabase = (String) emailSnapshot.getValue();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {}
});
This is the database structure in my Firebase console.
amapp-731b2addclose
+ messages
+ version
- userslist
- email
|
| -- 0: "abc@gmail.com"
| -- 1: "xyz@gmail.com"
| -- 2: "ghi@gmail.com"
| -- 3: "mno@gmail.com"