I am new, any one can help me, I am trying to get data from firestore, data is retrieving and I viewed in Log but in the list that I am trying to initialize.
Here is my code:
public List<TestQuestion> getListOfQuestions() {
listOfQuestions = new ArrayList<>();
db.collection("TestQuestions")
.whereEqualTo("test_level",1)
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
listOfQuestions.add(document.toObject(TestQuestion.class));
Log.d(TAG, "Questions = " + document.getData());
}
} else {
Log.d(TAG, "Error getting documents: ", task.getException());
}
}
});
return listOfQuestions;
}
In Log
D/ContentValues: Questions = {option_d=op d, option_b=op b, option_c=op c, question=my first question, subject=English, test_level=1, right=1, option_a=op a} D/ContentValues: Questions = {option_d=op d, option_b=op b, option_c=op c, question=my second question, subject=English, test_level=1, right=2, option_a=op a} D/ContentValues: Questions = {option_d=op d, option_b=op b, option_c=op c, question=my third question, subject=English, test_level=1, right=2, option_a=op a}
listOfQuestions size is 0