Java 获取firestore中子集合的id

Java 获取firestore中子集合的id,java,android,google-cloud-firestore,Java,Android,Google Cloud Firestore,我在Firestore中有以下结构 private FirebaseFirestore db; db.collection("abc").document(FirebaseAuth.getInstance().getCurrentUser().getUid()).collection("def"); 我正在用这段代码获取子集合的id String subCollectionId; subCollectionId=db.collection("a

我在Firestore中有以下结构

private FirebaseFirestore db;
db.collection("abc").document(FirebaseAuth.getInstance().getCurrentUser().getUid()).collection("def");
我正在用这段代码获取子集合的id

String subCollectionId;
subCollectionId=db.collection("abc").document(FirebaseAuth.getInstance().getCurrentUser().getUid()).collection("def").getId();

但此代码将返回“def”字符串而不是id

请将您的代码添加为格式化代码。检查此链接我不确定是否理解您的问题:子集合的ID是
def
,因此第二个片段返回该ID是正确的。您期望的值是什么?每个Firestore集合都有一个id,如(mPgp7Z8uDJS6fk6etOzEIjzIgSo2)。我想获取子集合的id我的子集合名称“def”。请使用所有必要的信息更新您的问题,以帮助您作出回答。您遵循了哪些文档,预期的行为是什么?