Skip to content

Instantly share code, notes, and snippets.

@kenny-io
Created October 11, 2017 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenny-io/cbd2147b190f2fcfb2d96f1d33cc6371 to your computer and use it in GitHub Desktop.
Save kenny-io/cbd2147b190f2fcfb2d96f1d33cc6371 to your computer and use it in GitHub Desktop.
private void addNewContact(){
Map<String, Object>newContact = new HashMap<>();
newContact.put(NAME_KEY, "John");
newContact.put(EMAIL_KEY, "john@gmail.com");
newContact.put(PHONE_KEY, "080-0808-009");
db.collection("PhoneBook").document("Contacts").set(newContact)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Toast.makeText(MainActivity.this, "User Registered",
Toast.LENGTH_SHORT).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this, "ERROR" +e.toString(),
Toast.LENGTH_SHORT).show();
Log.d("TAG", e.toString());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment