0

There is some data in my firebase store and this data is being propagated to my app but after some time I want to remove that data from my app (when the data is too old). I want to know how can I do this, when I delete data from firebase, the data from app should be deleted.

this.mfirebasefirestore= FirebaseFirestore.getInstance();
mfirebasefirestore.collection("Users").addSnapshotListener(new EventListener<QuerySnapshot>() {
    @Override
    public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots,
                        @Nullable FirebaseFirestoreException e) {
        if(e!=null){
            Log.d(TAG,"Error");
            return;
        }
        assert queryDocumentSnapshots != null;
        for(DocumentChange doc:queryDocumentSnapshots.getDocumentChanges()){
            if(doc.getType()==DocumentChange.Type.ADDED){
                Users users=doc.getDocument().toObject(Users.class);
                usersList.add(users);
                usersListAdapter.notifyDataSetChanged();
            }
        }
    }
});
Bob Dalgleish
  • 8,057
  • 4
  • 31
  • 41
Anonymous
  • 15
  • 6

1 Answers1

0

I think the best way is to write Cloud Function which after some time will be removing old data.

https://firebase.google.com/docs/functions/

Or you could do something like this: How to delete firebase data after "n" days

Andropogon
  • 694
  • 7
  • 28
  • I dont want to delete the firebase data from app. I want to remove the data of the app from firebase. – Anonymous Mar 19 '19 at 22:00
  • This solution that I pasted above is about deleting data from firebase. Try solution of @Frank van Puffelen, it is deleting data from firebase older than 30 days. – Andropogon Mar 19 '19 at 22:09