I am making an Android application using Firebase
realtime database. When a new user registers on my app, that user\'s data is saved in the Firebase database. <
Since you have already got a solution to your problem, I will try to explain why your code was not working.
DatabaseReference fdbRefer = FirebaseDatabase.getInstance().getReference("Users/"+username);
You might be thinking that in the above statement fdbRefer
will be null if "Users/"+username is not present in the database.
But actually, this statement will only store a path to the specified field in getReference()
. So when you check for fdbRef!=null
, it is always true because fdbRefer
will hold value something like 'https://.firebase.com/Users/Nick123.