Preliminary Note: I am running a method called getStatesList(), which returns an ArrayList. I am using this in tandem with a Runnable, which collects the data a few seconds later and updates the view. Basically, I run the call during onResume() so the user will see the activity, showing that it is loading data. If I retrieve the data successfully, that is great. If not, the user can retry (and check internet connection). About 99 percent of the time, I am able to retrieve the queried data.
My Question: I am having an issue collecting ALL documents within my root collection, "DATA". I run the below code (in tandem with a Runnable), but only "CA" shows up in the results. I believe this is because both "AL" and "MI" are no longer documents, but references to other collections, which I have named sub-1 and sub-2 for this example. I have added an image to aid in my explanation. Why can I retrieve "CA" but not the other documents?
Also, is there a term for documents that point to collections? Knowing this may help me find a solution.
public ArrayList<String> getStatesList(){
db.collection("DATA").get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(task.isSuccessful()) {
// In this example, I get one result returned ("CA")
for(QueryDocumentSnapshot document : task.getResult()){
states.add(document.getId());
}
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
states = null;
}
});
return states;
}
**UPDATE 2/3/2020: I found that if I add a field to "AL", it will show up in the query. However, I'd still rather not add fields where they are not necessary. I'll do this for now, but I'd prefer a solution that doesn't require needless data. I'd also like to point out that "CA" has always shown up in the query without a single field of data. Any explanation for this?