Reputation: 4121
I'm trying to perform login
operation in my app using firebase
my Users
node is something like:
mUserCompounds.orderByChild("email").equalTo("[email protected]").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
System.out.println(dataSnapshot.getChildrenCount()); }
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
i want to get that complete object
with which i have matched the name. so that
i can also compare password etc. Thanks for help.
Upvotes: 2
Views: 453
Reputation: 2827
First make a pojo class of User data .
Class User {
String about;
String email;
String image;
String name;
String password;
String pointsTotal;
String totalTasksDone;
}
Make getter setters and define constructors.
mUserCompounds.orderByChild("email").equalTo("[email protected]").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
//User already exists
User user1 = dataSnapshot.getValue(User.class);
System.out.println(user1.getPassword());
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Upvotes: 1
Reputation: 2021
this is pretty simple
mUserCompounds.orderByChild("email").equalTo("[email protected]").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.i("your tag",""+dataSnapshot.toString());
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Upvotes: 1
Reputation: 512
Visit the Firebase documentation enter link description here
read firebase data Also always push data to firebase with Pushkey so you can get whole object.
Upvotes: 2