ThesetValue() method overwrites data at the specified location, including any child nodes.
You can use this method to:
This is an example with a CustomObject.
First define the object.
@IgnoreExtraProperties
public class User {
    public String username;
    public String email;
    public User() {
        // Default constructor required for calls to DataSnapshot.getValue(User.class)
    }
    public User(String username, String email) {
        this.username = username;
        this.email = email;
    }
Then get the Database reference and set the value:
   User user = new User(name, email);
   DatabaseReference mDatabase mDatabase = FirebaseDatabase.getInstance().getReference();
   mDatabase.child("users").child(userId).setValue(user);