最佳答案
如果您想获取该特定文档,可以尝试此操作
DocumentReference docRef = db.collection("projects").document("YOURDOCIDHERE");
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document.exists()) {
Log.d(TAG, "DocumentSnapshot data: " + document.getData());
} else {
Log.d(TAG, "No such document");
}
} else {
Log.d(TAG, "get failed with ", task.getException());
}
}
});
如果您想按按键顺序获取所有文档,那么您可以尝试进行这样的查询。
docRef.orderByKey()
查看 firebase 文档以获取更多信息。
关于Android Firestore通过文档id获取字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62548387/