1DocumentReference docRef = db.collection("cities").document("SF");
2docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
3 @Override
4 public void onComplete(@NonNull Task<DocumentSnapshot> task) {
5 if (task.isSuccessful()) {
6 DocumentSnapshot document = task.getResult();
7 if (document.exists()) {
8 Log.d(TAG, "DocumentSnapshot data: " + document.getData());
9 } else {
10 Log.d(TAG, "No such document");
11 }
12 } else {
13 Log.d(TAG, "get failed with ", task.getException());
14 }
15 }
16});