If I have a Firebase Firestore database which I have retrieved a DocumentSnapshot
for the document corresponding to the collection on the right and stored in a
You need to do a DocumentReference
to get the content in your document.
A simple one will be like this.
DocumentReference docRef = myDB.collection("users").document("username");
docRef.get().addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document != null) {
Log.i("LOGGER","First "+document.getString("first"));
Log.i("LOGGER","Last "+document.getString("last"));
Log.i("LOGGER","Born "+document.getString("born"));
} else {
Log.d("LOGGER", "No such document");
}
} else {
Log.d("LOGGER", "get failed with ", task.getException());
}
}
});
The downside is that you need to know your document ID to get the field values.