1

I am trying to get data from fields on my firebase firestore, but not the whole document. Fields that i want

Here is my code that get the whole document.

db.collection("Reminder").get()
            .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
                @Override
                public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
                    if (!queryDocumentSnapshots.isEmpty()) {
                        List<DocumentSnapshot> list = queryDocumentSnapshots.getDocuments();

                        for (DocumentSnapshot d : list) {
                            dbReminder p = d.toObject(dbReminder.class);
                            p.setId(d.getId());
                            remtasklist.add(p);
                        }
                        adapter.notifyDataSetChanged();

                    }
                }
            });

Thanks in advance. Edit: I updated with the collection pic. Collection

1 Answers1

0

You can get specific fields from the documentSnapshot.

 String location = documentSnapshot.getString("inLocation");
 String time = documentSnapshot.getString("time");//assuming time here is string
 String title = documentSnapshot.getString("title");
bensadiku
  • 436
  • 3
  • 15