I'm trying to convert a field which has an array in Firebase Cloud Firestore. The field is stored in a document and contains 10 values in the field.
I can get the data using the following code however I would like to know if its possible to convert this data into a List?
public void getAllowedPostcodes(){ DocumentReference docRef = db.collection("AllowedPostcodes").document("tmGzpfFPFTwGw28uS8y1"); docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() { @Override public void onComplete(@NonNull Task<DocumentSnapshot> task) { if (task.isSuccessful()) { DocumentSnapshot document = task.getResult(); if (document != null) { Log.d(TAG, "DocumentSnapshot data: " + task.getResult().getData()); } else { Log.d(TAG, "No such document"); } } else { Log.d(TAG, "get failed with ", task.getException()); } } }); }
I have tried the following however, it doesn't compile saying:
"Cannot resolve constructor 'ArrayList(java.util.Map<java.lang.String,java.lang.Object>)"
This is my code:
List<String> allowedData = new ArrayList<String>(task.getResult().getData());