Get all the fields of a document

0

How can I get all the fields of a Firestore document. For example if in a collection I have several documents, and in each document I have fields; but each of these documents does not have the same number of fields, some have more and others less, even those fields are different in each document. I'm trying to get those fields in a list but I can not use getString (), since I do not know what fields a document has at any given moment.

fsdbData.collection("class")
            .orderBy("nom")
            .addSnapshotListener(new EventListener<QuerySnapshot>() {
                @Override
                public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) {
                    if (e != null) {
                        Log.d("Ex", "Excepcion", e);
                        return;
                    }
                    if (queryDocumentSnapshots.size() != 0) {
                        lisClases.clear();
                        adaClases.notifyDataSetChanged();
                    }
                    for (QueryDocumentSnapshot doc : queryDocumentSnapshots) {
                        doc.
                        lisClases.add(new ItemClase(
                                doc.getString("nom"),

                        ));
    
asked by Jose Rosales 15.11.2018 в 07:17
source

1 answer

0

The getData of a DocumentSnapshot returns you a Map , you can get the list of fields there with keySet .

    
answered by 16.11.2018 в 17:15