Java 我正在使用android studio和firestore。在我的应用程序中,当管理员添加详细信息时,会成功添加,但不会';t显示用户登录的时间

Java 我正在使用android studio和firestore。在我的应用程序中,当管理员添加详细信息时,会成功添加,但不会';t显示用户登录的时间,java,android,firebase,google-cloud-firestore,Java,Android,Firebase,Google Cloud Firestore,此代码用于从Firestore检索数据,用户可以看到它,但它只显示给出的提示 package com.example.e_computerservices; public class Viewtesting extends AppCompatActivity { TextView name,email,phoneno; FirebaseAuth fAuth; FirebaseFirestore fStore; String userId; @Overr

此代码用于从Firestore检索数据,用户可以看到它,但它只显示给出的提示

package com.example.e_computerservices;

public class Viewtesting extends AppCompatActivity {
    TextView name,email,phoneno;
    FirebaseAuth fAuth;
    FirebaseFirestore fStore;
    String userId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_viewtesting);
        name=findViewById(R.id.Name);
        email=findViewById(R.id.Email);
        phoneno=findViewById(R.id.PhoneNo);

        fAuth=FirebaseAuth.getInstance();
        fStore=FirebaseFirestore.getInstance();
        userId=fAuth.getCurrentUser().getUid();
        DocumentReference documentReference=fStore.collection("Users").document(userId);
        documentReference.addSnapshotListener(Viewtesting.this, new EventListener<DocumentSnapshot>() {
            @Override
            public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {

                name.setText(documentSnapshot.getString("Name"));
                email.setText(documentSnapshot.getString("UserEmail"));
                phoneno.setText(documentSnapshot.getString("PhoneNumber"));
            }
        });


    }
}
package com.example.e_computerservices;
公共类Viewtesting扩展了AppCompative活动{
文本视图名称、电子邮件、电话号码;
弗斯;
FirebaseFirestore商店;
字符串用户标识;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_viewtesting);
name=findviewbyd(R.id.name);
email=findviewbyd(R.id.email);
phoneno=findviewbyd(R.id.phoneno);
fAuth=FirebaseAuth.getInstance();
fStore=FirebaseFirestore.getInstance();
userId=fAuth.getCurrentUser().getUid();
DocumentReference=fStore.collection(“用户”).document(userId);
documentReference.addSnapshotListener(Viewtesting.this,new EventListener()){
@凌驾
public void OneEvent(@Nullable DocumentSnapshot DocumentSnapshot,@Nullable FirebaseFirestoreException e){
name.setText(documentSnapshot.getString(“name”));
email.setText(documentSnapshot.getString(“UserEmail”);
phoneno.setText(documentSnapshot.getString(“PhoneNumber”);
}
});
}
}
更新默认提示后,仅显示:

数据库:


不显示数据的问题是数据库中字段的命名。要解决此问题,请更改以下代码行:

name.setText(documentSnapshot.getString("Name"));
email.setText(documentSnapshot.getString("UserEmail"));
phoneno.setText(documentSnapshot.getString("PhoneNumber"));
致:


请参见,所有属性都应以小写字母开头,而不是以大写字母开头。请记住,您应该根据数据库中存在的属性获取数据。

请编辑您的问题,并将您的数据库结构添加为屏幕截图。当然,您可以使用。我已更新,请检查。我已获取。我马上写一个答案。
name.setText(documentSnapshot.getString("name"));
email.setText(documentSnapshot.getString("userEmail"));
phoneno.setText(documentSnapshot.getString("phoneNumber"));