Skip to content

Instantly share code, notes, and snippets.

@kenny-io
Created October 12, 2017 00:16
Show Gist options
  • Save kenny-io/2bd3d4619acb8f9177e42b1bb777b9e3 to your computer and use it in GitHub Desktop.
Save kenny-io/2bd3d4619acb8f9177e42b1bb777b9e3 to your computer and use it in GitHub Desktop.
private void addNewContact(){
save = findViewById(R.id.save);
name = findViewById(R.id.name);
email = findViewById(R.id.email);
phone = findViewById(R.id.phone);
String mName = name.getText().toString();
String mEmail = email.getText().toString();
String mPhone = phone.getText().toString();
Map<String, Object>newContact = new HashMap<>();
newContact.put(NAME_KEY, mName);
newContact.put(EMAIL_KEY, mEmail);
newContact.put(PHONE_KEY, mPhone);
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();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment