Reputation: 45
im new in android and im using SharedPreference of android for storing some states of the buttons, lets say storing the active state and unactive state of the button in SharedPreferences. But problems occurs whenever my application crashes, i want to clear my all preferences (i.e. making the button state on default value).
so i was wondering that is there any way i can clear my app's preferences whenever my application crashes.
Thanks
Upvotes: 0
Views: 534
Reputation: 43023
By definition, when an application crashes, it means an exception that has not been caught happened. If you're not catching this exception, you cannot do any action.
Try to analyse the cause of the crash and fix it rather than relying on crashing as a normal course of action.
Upvotes: 0
Reputation: 8621
I would suggest to re-write your app so it doesn't crash, an app crash is a terrible user experience ! Then handle the SharedPreferences is a safer way ...
Upvotes: 1