How Can I Update My Information In Different Location? Android Firebase
Click this to see Firebase Data Structure I want to update my information (firstname, middlename, lastname) which is in a different location. I'm updating my information using stud
Solution 1:
To update a record in a Firebase database, you can use setValue()
method directly on the reference
. Assuming that teacher
is the direct child of the Firebase root, you can use this code:
DatabaseReferencerootRef= FirebaseDatabase.getInstance().getReference();
DatabaseReferencefirstNameRef= rootRef.child("teacher").child(teacherId).child("class").child(classId).child("Listofstudents").child(listId).child("firstname");
firstNameRef.setValue("New Name");
In which teacherId
, classId
and listId
are those random generated keys that i see in your database.
If you want to update the same data, in a different location, just add another reference to desired location and use the same setValue()
method.
Hope it helps.
Post a Comment for "How Can I Update My Information In Different Location? Android Firebase"