Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FirestoreRecyclerAdapter how do I get the key

With new firestore how do I get the key (document ID) from adapter?

With Firebase Database we get this with

String key = this.getRef(position).getKey();
like image 607
EagerToSing Avatar asked Jan 04 '23 06:01

EagerToSing


1 Answers

Was just having the same problem. This works for me. FirestoreUI version 3.1.0.

Within your onBindViewHolder, (and note you will need to make "position" final):

                        String docId = getSnapshots().getSnapshot(position).getId();

                        Log.d("GETREFTEST", docId);

Happy coding.

like image 178
Jeff Padgett Avatar answered Apr 25 '23 20:04

Jeff Padgett