是否可以仅在Firebase上更新我孩子的特定数据? [英] Is it possible to update only specific data on my child on firebase?

查看:55
本文介绍了是否可以仅在Firebase上更新我孩子的特定数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否只能在android Firebase上更新某个用户的数据?如果例如我正在使用管理员帐户在哪里可以专门更新所有用户,该怎么办?

Is it possible to only update the data of a certain user on my android Firebase?How can I do it, if for example I'm using an admin account where can I update all user specifically?

例如在我的Firebase数据库上

For example on my firebase database

我只想更新SCYQ的用户详细信息---我想更改名称,电子邮件,日期.仅在不影响其他用户信息的情况下显示该用户?

I only want to update the user details of SCYQ--- I want to change the name,email,date. of the user only without affecting the information of other users?

推荐答案

是的,有可能:

FirebaseUser user=FirebaseAuth.getInstance().getCurrentUser();
String useruid=user.getUid();
DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("Accounts").child("user").child(useruid);
ref.child("date").setValue(newdate);
ref.child("email").setValue(newemail);
ref.child("name").setValue(newname);
ref.child("type").setValue(newtype);

如果您在列表视图中有名称列表,并且想要更新它们,则可以执行以下操作:

If you have the list of names in a listview and you want to update them then, you can do the following:

listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final String selectedFromList = (String) listview.getItemAtPosition(position);
DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("Accounts").child("user").child(useruid);
ref.orderByChild("name").equalTo(selectedFromList).addValueEventListener(new ValueEventListener(){
 @Override
 public void onDataChange(DataSnapshot dataSnapshot) {

  //update values here
     }
  }

   @Override
 public void onCancelled(FirebaseError firebaseError) {

            }
        });
    });

这篇关于是否可以仅在Firebase上更新我孩子的特定数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆