I have some problems related to my database, and the docs seems a lot of confusing i can't figure out how to solve that, basicly i have my user data in the firebase, and i want to see if in my user with some id i already have the key username if yes i want to update with some data of my form, if no i want to add a value based on my form, but when i want to know how to check if the id already exist, i did this:
auth = FirebaseAuth.getInstance();
database = FirebaseDatabase.getInstance();
myRef = database.getReference();
userId = auth.getCurrentUser().getUid();
user = myRef.child("Users").child(userId);
Log.d("test1",String.valueOf(user.child("age").getKey()));
if(user.child("username").co){
usernameTxt.setText(user.child("username").toString());
}
if(user.child("age") != -1){
usernameTxt.setText(user.child("age").toString());
}