1Map<String, Object> city = new HashMap<>();
2city.put("name", "Los Angeles");
3city.put("state", "CA");
4city.put("country", "USA");
5
6db.collection("cities").document("LA")
7 .set(city)
8 .addOnSuccessListener(new OnSuccessListener<Void>() {
9 @Override
10 public void onSuccess(Void aVoid) {
11 Log.d(TAG, "DocumentSnapshot successfully written!");
12 }
13 })
14 .addOnFailureListener(new OnFailureListener() {
15 @Override
16 public void onFailure(@NonNull Exception e) {
17 Log.w(TAG, "Error writing document", e);
18 }
19 });
20