setValueAsync(无法解析 'DatabaseReference' 中的方法 'setValueAsync')

setValueAsync (Cannot resolve method 'setValueAsync' in 'DatabaseReference')

我正在执行本指南 link,但我无法调用 setValueAsync,我收到错误无法解析 'DatabaseReference' 中的方法 'setValueAsync'。我看到我可以在设置 String 的开始使用它,但我不知道它对我有什么帮助。谢谢大家

我的代码:

public class MessageMembersList extends Fragment implements View.OnClickListener {
    private Button btnConnectToServer;
    FirebaseAuth mAuth;
    FirebaseUser user;
    String curentName;
    String curentLastName;
    String curentEmail;
    String Name;
    String LastName;
    String Email;

    public Users(String Name, String LastName, String Email) {

        this.Name = Name;
        this.LastName = LastName;
        this.Email = Email;

    }

    public void onViewCreated(View view, Bundle savedInstanceState) {
        btnConnectToServer = (Button) getView().findViewById(R.id.btnConnectToServer);
        mAuth = FirebaseAuth.getInstance();
        btnConnectToServer.setOnClickListener(this);
        user = mAuth.getCurrentUser();

                    FirebaseDatabase database = FirebaseDatabase.getInstance();
                    DatabaseReference myRef = database.getReference().child("No server").child(user.getUid());
                    myRef.addValueEventListener(new ValueEventListener() {
                        @Override
                        public void onDataChange(@NonNull DataSnapshot datasnapshot) {
                            curentName = (String) datasnapshot.child("name").getValue().toString();
                            curentLastName = (String) datasnapshot.child("lastName").getValue().toString();
                            curentEmail = (String) datasnapshot.child("email").getValue().toString();

                            txt1.setText(Name);

                        }


                        @Override
                        public void onCancelled(@NonNull DatabaseError error) {

                        }
                    });
}
}

错误部分 setValueAsync(无法解析 'DatabaseReference' 中的方法 'setValueAsync')。 用户有错误,但我不会在这个问题中谈论它。

 @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btnConnectToServer:
                connectedToServer = false;
                        WifiManager wifiManager = (WifiManager) getActivity().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
                        WifiInfo info = wifiManager.getConnectionInfo();
                        String ssid = info.getSSID();
                        serverName = ssid;

                        FirebaseDatabase database = FirebaseDatabase.getInstance();
                        DatabaseReference myRef = database.getReference().child(ssid);

                        myRef.child(user.getUid()).setValueAsync(new Users(curentName,curentLastName,curentEmail));

                        break;
                    }
    }

setValueAsync() 方法是 Firebase Admin SDK and does not work in Android. If you need to add a value to the Realtime Database in an Android fragment, you have to use the Fireabse Android SDK and use setValue() method as explained in the official documentation for writing data 的一部分。