在字符串中将文档添加到 firestore 后,我需要获取文档 ID
Java android studio Firebase
Map<String, Object> doctor = new HashMap<>();
doctor.put("name", name);
doctor.put("specialty", specialty);
doctor.put("address", address);
doctor.put("price", price);
doctor.put("times", times);
doctor.put("img_url", name);
CollectionReference dbDoctor = db.collection(addString);
dbDoctor.add(doctor).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
Toast.makeText(BookingAdd.this, "Added Done", Toast.LENGTH_LONG).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(BookingAdd.this, "Fail to add \n" + e, Toast.LENGTH_LONG).show();
}
});