Skip to content Skip to sidebar Skip to footer

Delete Data From Firestore

I have add data on firestore Firebase but I don't have specific document because I use addSnapShotListener to retrieve the data. How can I delete the document when I don't know the

Solution 1:

document() returns a DocumentReference object. That object gives you everything you need to know to delete it, especially its own delete() method. It also has a getId() method to help you remember its id.

So, you should store the DocumentReference object first before calling methods on it:

DocumentReference ref = mondayCollectionReference.document()
String id = ref.getId();
ref.set(...);
// use ref or id later if you want to delete it

Post a Comment for "Delete Data From Firestore"