I try to make arraylist from the firestore. When I run the code the app got crashes. Do I need to add something here to make the app run? And how can I get all the document in firestore that have unique id?
public String load() {
contentList = new ArrayList<>();
contentList.clear();
firebaseFirestore.collection("plans").document("W1ls1b0lYNw9hxyuJyJ5").collection("versions").get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot doc : task.getResult()) {
String List = doc.getString("content");
contentList.add(List);
}
Log.d(TAG, "Length is:"+ " => " + contentList.size());
Log.d(TAG, "a : =>" + contentList.get(0));
Log.d(TAG, "b : =>" + contentList.get(1));
Log.d(TAG, "c : =>" + contentList.get(2));
Log.d(TAG, "d : =>" + contentList.get(3));
}else {
Log.e(TAG, "Firestore error");
}
}
});
return contentList.get(0).toString();
//contentList.get(0).toString()
}