java - Android Java - 如何在将文档添加到 Firestore 后获取文档 ID
问题描述
在将文档添加到字符串中的 Firestore 后,我需要获取文档 ID
Java 安卓工作室 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();
}
});
解决方案
推荐阅读
- c# - 无法使用带有承载令牌 .net 核心 MVC 的 api 对 Azure 广告用户进行身份验证
- ios - 如何在我的应用程序的 iPhone 存储中的应用程序设置页面中添加项目
- python - 用十六进制转义表示的 Python 3 字符串
- azure-devops - 有没有办法通过 Azure Pipelines 上的一项任务将 CRM 解决方案导入多个组织?
- reactjs - 如何使一个组件在 React 中从其他相同组件中脱颖而出
- jquery - 如何传递值查询字符串
- jenkins - 调用不带参数的共享库函数
- linux - Pumba 安装 - 在 linux 终端上找不到命令
- r - R tmap如何只显示1个图例
- sql - SQL Server:按列值查找重复记录