I'm trying to add a new child using the `DatabaseReference` in my `Firebase` Android app. I'm doing: 

```
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference() 
mDatabase.child("childToAdd").setValue(1);

```

I can do this with a regular `Firebase` Reference as it would add the child to the database if it isn't there.  

How could I go about doing this with `DatabaseReference`? 

Edit: Thanks for all the suggestions but I'm having issues with the following code. When it enters the if block it does not push the data onto the database. 

<https://gist.github.com/rounaksalim95/a5cba332400c6caf8320f15b0cbf06e8>

When I try this with the old Firebase reference I get error code 11 (User code called from firebase runloop) and with the new database reference I get error code -3 (PermissionDenied even though I have no security rules). 

Update:

I got it to do what I wanted to using a single value event listener: 

```
Firebase userRef = new Firebase(BASEURL + "userData");

userRef.addListenerForSingleValueEvent(new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        if (dataSnapshot.child(user.getUid()).getValue() == null) {
            userRef.child(user.getUid()).setValue(1);
        }
    }

    @Override
    public void onCancelled(FirebaseError firebaseError) {

    }
});  

```

However database reference doesn't let me add values like this.