June 2018
Beginner to intermediate
394 pages
9h 2m
English
In Firestore, there are two methods to retrieve data. Call a method to retrieve data and set the listener to receive the data change events.
The following example shows how to retrieve content from a document:
DocumentReference docRef = db.collection("cities").document("SF");docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() { @Override public void onComplete(@NonNull Task<DocumentSnapshot> task) { if (task.isSuccessful()) { DocumentSnapshot document = task.getResult(); if (document.exists()) { Log.d(TAG, "DocumentSnapshot data: " + document.getData()); } else { Log.d(TAG, "No such document"); } } else { Log.d(TAG, "get failed with ", task.getException()); } }});
Developers can retrieve the data of ...
Read now
Unlock full access