List<String> uniNames = new ArrayList<>();
FirebaseFirestore db = FirebaseFirestore.getInstance();
CollectionReference unisRef = db.collection("Universities");
unisRef.get().addOnCompleteListener(task -> {
if(task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
uniNames.add(document.getString("name"));
}
} else {
Log.d("MainActivity", "Error getting documents: ",
task.getException());
}
});
I am trying to get all the values of the field name from my documents in the university collection but the .get() just doesn't seem to execute at all. it connects to the database just fine and i get a collectionreference object but the .get() just gets skipped completely so i end up with an empty List. Am i using the oncomplete listener wrong or missing something trivial?