我怎样才能在不同的位置更新我的信息? Android Firebase [英] How can i update my information in different location? Android Firebase
问题描述
我想更新我的信息(名字,中间名,姓氏),这是在不同的位置。我正在使用学生帐户更新我的信息。它只在学生下更新,但我不知道如何在老师下更新。如果我更新我的名字,中间名,姓氏,我还希望我的名字,中间名和姓氏更新也在课下的两个部分下。请帮帮我。要更新Firebase数据库中的记录,您可以使用 setValue()$ c 直接在
引用
上使用$ c>方法。假设 teacher
是Firebase根目录的直接子项,您可以使用以下代码:
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);
其中 teacherId
, classId
和 listId
是我在数据库中看到的那些随机生成的键。
<如果你想更新相同的数据,在不同的位置,只需添加另一个引用到所需的位置,并使用相同的
setValue()
方法。 希望有帮助。
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 student account. It only update under student but I don't know how to update it under teacher. If I update my first name, middle name, last name, I want my first name, middle name, and last name update also under the two section under the class. Please help me.
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.
这篇关于我怎样才能在不同的位置更新我的信息? Android Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!