I'm trying to retrieve a child in my database so a user can join a group however when I do the method it gives me a NullPointerException
because it goes to the return first how do I get it to go into the retrieval first?
public int groupCheck(String GrN, String Pass) {
final String GN = GrN;
DatabaseReference myRef = database.getReference("GROUPS").child("GROUP").child(GN);
myRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
groupNam = dataSnapshot.getValue().toString();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
if (groupNam.equals(GroupN)) {
return 1;
} else {
return 0;
}
}