Issue
Im having a database as below,
Here, I want to dynamically delete the existing list "20211127", and add a new list with a different name in place of deleted one.
I have been going over this issue for 6 days now, without a solution. Could you please help me with this?
Solution
To remove the existing node and add a new node in one operation would be something like this:
String listToDelete = "20211127";
String listToAdd = "20220629";
Map dataToAdd = ...; // 👈 You have to provide this
Map updates = new HashMap<String, Object>();
updates.put("cafeTrans/"+listToDelete, null);
updates.put("cafeTrans/"listToAdd, dataToAdd);
FirebaseDatabase.getInstance().getReference().updateChildren(updates);
Answered By - Frank van Puffelen
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)