'How to get key from QuerySnapshot in android firestore
Above is an image of my database.The three fields have other info linked to them.
I want to store the names of these three documents (Joke Writing, Negotiation, Psychology) in a list. Here is what I'm doing:
List<String> na = new ArrayList<>();
db.collection("courses").get().addOnCompleteListener(task -> {
for(DocumentSnapshot document:task.getResult().getDocuments()){
na.add((String) document.get("key"));
}
Log.i("TAG", String.valueOf(na));
});
However, na is printing [null,null,null]. How can I get the keys?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

