I'm trying t get an ArrayList
with all the field names from a document and convert it to an ArrayList
.
I've been able to do this from a collection where I put all the documents in a ArrayList
but I can't do it from a document.
Below is the code for all the documents from a colection and an image of the data base and what I want.
names_clinics= new ArrayList<>();
mFirebaseFirestore = FirebaseFirestore.getInstance();
mFirebaseFirestore.collection("CodeClinic")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
names_clinics.add(document.getId());
Log.d("CLINIC CODE", document.getId() + " => " + document.getData());
}
} else {
Log.d("CLINIC CODE", "Error getting documents: ", task.getException());
}
}
});
Thank you :D
To print those property names, please use the following code:
The output will be: