I'm trying to edit the name of the classroom shown in the image below without losing the children data, how to do that in android ?
Asked
Active
Viewed 676 times
0

Rosário Pereira Fernandes
- 11,015
- 6
- 55
- 79

Abdullah Yahya
- 119
- 1
- 10
-
Is that the only key you want to edit? Or will you need to edit more keys in the future? – Rosário Pereira Fernandes Jan 13 '18 at 12:34
-
There is no API call to rename a key. You'll have to create a new node with the data and delete the old one. See https://stackoverflow.com/questions/39107274/is-it-possible-to-rename-a-key-in-the-firebase-realtime-database, https://stackoverflow.com/questions/46449627/how-can-i-rename-a-branch-node-in-firebase, https://stackoverflow.com/questions/43510725/how-to-update-the-node-key-in-firebase, https://stackoverflow.com/questions/40456443/how-to-move-firebase-child-from-one-node-to-another-in-android – Frank van Puffelen Jan 13 '18 at 15:42
1 Answers
0
There is no way for doing this. There is no API that allows you to change the name of a node in a Firebase database. What can you do instead, is to create another node with the desired name, containing the same childrens and then remove the old one.

Alex Mamo
- 130,605
- 17
- 163
- 193
-
-
The flow as follows: attach a listener on `11B Boys` node, get the `DataSnapshot` object and then write it in the same location with another name. Also don't forget the remove the old one. That's it! – Alex Mamo Jan 13 '18 at 12:24