Reputation: 170
I need to retain some information so that I can access it when I launch my app after it is closed. I need to use that information on 'onCreate()' of my 'MainActivity'. But I need to clear/reset those information if the mobile is rebooted. So how do I know in the program if the mobile has been rebooted and the activity is launched for the first time after reboot?
Upvotes: 1
Views: 75
Reputation: 82563
Listen for the BOOT_COMPLETED
broadcast to know when the phone has been turned on.
Then use SharedPreferences.Editor.clear()
followed by a commit()
to delete all data for your app.
Upvotes: 6