Skip to content

Instantly share code, notes, and snippets.

@kenny-io
Created October 11, 2017 23:51
Show Gist options
  • Save kenny-io/2dc6dd1f1f60d05048f9e0a6c9c6fa45 to your computer and use it in GitHub Desktop.
Save kenny-io/2dc6dd1f1f60d05048f9e0a6c9c6fa45 to your computer and use it in GitHub Desktop.
private void ReadSingleContact() {
DocumentReference user = db.collection("PhoneBook").document("Contacts");
user.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()){
DocumentSnapshot doc = task.getResult();
StringBuilder fields = new StringBuilder("");
fields.append("Name: ").append(doc.get("Name"));
fields.append("\nEmail: ").append(doc.get("Email"));
fields.append("\nPhone: ").append(doc.get("Phone"));
textDisplay.setText(fields.toString());
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment