Skip to content

Instantly share code, notes, and snippets.

@kenny-io
Created October 12, 2017 01:07
Show Gist options
  • Save kenny-io/76671765f10159ad386f673f5b52178d to your computer and use it in GitHub Desktop.
Save kenny-io/76671765f10159ad386f673f5b52178d to your computer and use it in GitHub Desktop.
private void addRealtimeUpdate() {
DocumentReference contactListener = db.collection("PhoneBook").document("Contacts");
contactListener.addSnapshotListener(new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(DocumentSnapshot documentSnapshot, FirebaseFirestoreException e) {
if (e != null ){
Log.d("ERROR", e.getMessage());
return;
}
if (documentSnapshot != null && documentSnapshot.exists()){
message.setText(documentSnapshot.getData().toString());
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment