xXNicolaXx
Lurker
Hi guys, I need to retrieve an arraylist saved in firestore which contains a list of partecipants that I have to put in a spinner. I can't figure out how to get the entire arraylist. That's my code:
The problem is that in this way, I get all the field of the document(you can see in the picture below) and even the partecipantsArray is bad formatting, because the name are all in a row, how you can see in the spinner screenshot.
There is a way to get only the array "partecipant" from the document and save it into another array?
Java:
public ArrayList<String> getPartecipantsList(){
String email = getEmail();
String groupTitle = getTitleBar();
DocumentReference docRef = db.collection("users").document(email).collection("Group").document(groupTitle);
docRef.get()
.addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
DocumentSnapshot document = task.getResult();
//Extracting participants ArrayList from the document
for(Object item : task.getResult().getData().values()) {
partecipantsArrayList.add(String.valueOf(String.valueOf(item).split(",")));
Log.v("vettore", String.valueOf(partecipantsArrayList));
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});
return partecipantsArrayList;
}
There is a way to get only the array "partecipant" from the document and save it into another array?
