Reputation: 327
I have the following structure in Firebase (this is but a small sample of a larger structure):
I'd like to be able to remove all the children of employees
node and keep the reference to it.
I noticed that if I remove all the children of a node, the parent gets removed as well.
Something like: (After all children are removed)
Is there any way to keep the reference?
Upvotes: 0
Views: 224
Reputation: 80914
You can do the following:
DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("employees").removeValue();
This will remove the whole node, then you can do:
DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("employees").setValue(0);
Upvotes: 1