Same question as: Android: Android: How to make a specific SharedPreference reset itself after the system reboots?
I don't know of a different way. This implementation is quite simple. Just handle the BOOT_COMPLETED broadcast action and clear preferences by calling .clear() on the SharedPreference.Editor (answer is here).
A simple Boot receiver might look like this:
public class OnBootReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
//clear preferences here
}
}
Declare it also in your AndroidManifest.xml as:
You will also need a permission for this: