33import android .app .AlertDialog ;
44import android .content .DialogInterface ;
55import android .content .Intent ;
6+ import android .content .SharedPreferences ;
67import android .os .Bundle ;
78
89import androidx .preference .Preference ;
10+ import androidx .preference .PreferenceManager ;
911
1012import org .schabi .newpipe .R ;
1113import org .schabi .newpipe .error .ErrorInfo ;
@@ -94,6 +96,7 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
9496
9597 // Resets all settings by deleting shared preference and restarting the app
9698 // A dialogue will pop up to confirm if user intends to reset all settings
99+ assert resetSettings != null ;
97100 resetSettings .setOnPreferenceClickListener (preference -> {
98101 final AlertDialog .Builder builder = new AlertDialog .Builder (getContext ());
99102 builder .setMessage ("Resetting all settings will discard "
@@ -113,9 +116,13 @@ public void onClick(final DialogInterface dialogInterface, final int i) {
113116 });
114117 final AlertDialog alertDialog = builder .create ();
115118 alertDialog .show ();
116- // SharedPreferences sharedPreferences =
117- // PreferenceManager.getDefaultSharedPreferences(requireContext());
118- // sharedPreferences = null;
119+
120+ // delete all shared preferences xml files.
121+ final SharedPreferences sharedPreferences =
122+ PreferenceManager .getDefaultSharedPreferences (requireContext ());
123+ sharedPreferences .edit ().clear ().apply ();
124+
125+
119126 return true ;
120127 });
121128 }
0 commit comments