I successfully managed to get the strings that are stored in the array of the database (Log.d("TAG", entry.getValue().toString());
shows the values of the strings of the array).
The strings are auto-generated document ids stored in an Array in Firestore, so the goal is getting 3 ids so I can make 3 queries to get the actual documents.
I am now stuck on how to attach the strings I got from Firestore to an ArrayList and then get 3 individual random strings from it.
I am relatively new to ArrayLists so any help is much appreciated!
Here is my code:
questionRef.document(tvCat1).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
Map<String, Object> map = document.getData();
for (Map.Entry<String, Object> entry : map.entrySet()) {
if (entry.getKey().equals("questions")) {
Log.d("TAG", entry.getValue().toString());
// Create function that gets 3 different values from the ArrayList and store them in 3 different Strings
}
}
}
}
});
Here is how I structured the database. Currently I am getting the ArrayList so I don't have so much reads. On the right you can see the documents I want to query when I have selected 3 random document ids from the ArrayList: