0

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 ?

my database structure

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 Answers1

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