且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我怎样才能在不同的位置更新我的信息? Android Firebase

更新时间:2023-02-04 22:18:09

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:

DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference firstNameRef = 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.