I am using Firestore adapter for my RecyclerView
and I am having trouble with the \'Delete\' button. When I press it, it deletes the wrong item instead of the one t
To delete a specific document from the database you'll need to know its ID. So that means when the user clicks on an item to delete, you'll need to be able to look up that item's document ID. For that reason you'll need to get both the values from the document and its ID when you're creating the view.
So in addition to the RewardModel
objects, you'll also need to keep the corresponding document IDs somewhere.
If you're using FirebaseUI to show the list, you can get the ID for a given position by following: Is there a way to get document ID of item from FirestoreRecyclerAdapter?
You are sending wrong data.
Query query = collectionReference.whereEqualTo("donationReq", (position + 1));
You had write position
instead of position + 1