I have a relative simple Firebase database which looks like this:
How can i update the Room1
node? If i use this code, in stead of updating that node, it adds another one, with the new name, Room2
.
databaseReference = FirebaseDatabase.getInstance().getReference().child("Rooms");
Query updateQuery = databaseReference.child(Room1).orderByKey().equalTo(Room1);
updateQuery.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
dataSnapshot.getRef().getParent().child("Room2").setValue("");
}
@Override
public void onCancelled(DatabaseError databaseError) {}
});
Thanks in advance!
with whatever new value you want in the setValue() parentheses