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:
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
You will also need a permission for this:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />