context is not available before onCreate
so you cannot use this
here:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor edit = prefs.edit();
put this inside onCreate like:
SharedPreferences prefs;
SharedPreferences.Editor edit;
and in onCreate
prefs = PreferenceManager.getDefaultSharedPreferences(this);
edit = prefs.edit();