JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Here it is always showing ERROR
// declarations
private FirebaseFirestore db=FirebaseFirestore.getInstance();
private DocumentReference noteref=db.collection("users").document("prof");
//typecasting as we have name also in xml
name=(TextView)findViewById(R.id.name);
//retrieving data from database, in database collections(user)-> document(prof)-> field(name)
noteref.get()
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
if(documentSnapshot.exists())
{
String name1=documentSnapshot.getString("name");
name.setText("NAME:"+name1);
}
else
{
Toast.makeText(third.this,"Profile not found",Toast.LENGTH_SHORT).show();
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run