1

I have this following method which i use when saving a new data

public void registerNewUser(FirebaseUser id, String name, String email, int count) { User user = new User(name, email, count); DatabaseReference ref = FirebaseDatabase.getInstance() .getReference(); ref.child("path") .child(id.getUid()).setValue(user); } 

I like to add a new data in the same child/folder when the user is done registering, this is what i have done so far.

 DatabaseReference ref = FirebaseDatabase.getInstance() .getReference(); ref.child("path") .child(id.getUid()).setValue("THE NEW DATA"); 

But the problem is it clears and overwrite the old data. Is there any efficient way to do this?

1 Answer 1

1

You can try this code

DatabaseReference ref = FirebaseDatabase.getInstance() .getReference(); ref.child("path") .child(id.getUid()+"/username").setValue(user); ref.child("path") .child(id.getUid()+"/newdata").setValue("THE NEW DATA"); 

Below Image Output Code

ref.child("path") .child(id.getUid()+"/username").setValue(["username": "isabellap"]); ref.child("path") .child(id.getUid()+"/build").setValue(["build": "1.0.7"]); 

Output

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, but i want it to joined the existing save data not just create a new child

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.