I am trying to add all the IDs of documents from a collection "Tasks" in a list call list. There is no error message but the list keeps coming empty. To try to find the error, whether it was not connecting to firebase or if there was another error, I added a toast message to see this and it showed that the for loop was running and it was retrieving the data but the list was still empty. I can assure you there is nothing wrong with the adapter or the recycler view. I am able to write to the firebase. Here is my code
CollectionReference collectionReference = db.collection("Tasks");
collectionReference
//.whereEqualTo("capital", true)
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
String s = document.getId();
list.add(s);
Toast.makeText(TaskList.this, document.getId(), Toast.LENGTH_SHORT).show();
}
} else {
}
}
});
mAdapter = new MyAdapter(list,this);
recyclerView.setAdapter(mAdapter);
Any help will be appreciated