I have created a function using Firestore query for getting the size of the documents, the Firestore query is working fine as I'm getting the result in LogCat of android. The problem with this function is that it is not returning the size of documents on the other end.
public String getDateFromFirestore(String UID, String animId){
db.collection("users").document(UID).collection("animals").
document(animalId).get().addOnCompleteListener(new
OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if(task.isSuccessful()){
size = task.getresults().getDocuments.size();
}
Log.w("Size:",String.valueOf(size));
}
});
return String.valueOf(size);
}
To retrieve the result of the function I am using the code below:
String size = getDateFromFirestore(UID, animId);