I have been using Firebase in my application successfully for several months. I just finished updating to use version 9.0.0, and I still have one problem that I cannot understand.
In my MainActivity onCreate function, I check if the user is logged into Firebase. If the user is logged in, I try to retrieve the user object that I have in my database.
This is the only instance of the application in which I am having problems with this. I checked that the user is logged in and the DatabaseReference pointed to the correct URL.
A DatabaseReference is created and the listener is added, but nothing on the listener never fires ...
FirebaseAuth auth = FirebaseAuth.getInstance();
if (auth != null && auth.getCurrentUser() != null) {
DatabaseReference userRef = FirebaseDatabase.getInstance().getReference().child(USERS).child(auth.getCurrentUser().getUid());
userRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
Any ideas on what I'm doing wrong?