Component used: WorkManager
Version used: 2.3.4
Devices/Android versions reproduced on: Any
Hi There - I want to delete a worker from workmanager queue even if it has completed or is running. I know I can cancel it when Worker is in RUNNING state, the problem is when it is FINISHED and FAILED I want to delete it. Workmanager.pruneWork() deletes all workers in WorkManager but I am looking to just remove a specific one.
Here is my scenario:
- I run a worker and it fails I return
results.failure() - Now I have a screen which show all Workers which are in
Failedstate. - All Failed Workers I have a option to remove or Retry
- User taps on (x) icon to remove Failed worker from UI and delete it from WorkInfoList so it doesn't show up again.
- If there is no option to remove single Worker then how can I remove it from WorkInfoList so next time user go to that screen he doesn't see the Failed Worker that he removed?
- Or if there is a option to change state from FAILED to CANCEL then I can just ignore cancelled ones?
- Also after how long WorkManager automatically purge its database?
Any help will be much appreciated. Thanks.