Skip to content

Commit 23de9bf

Browse files
plasticanuTobiGr
authored andcommitted
clear shared preference xmls
1 parent 5c46412 commit 23de9bf

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

app/src/main/java/org/schabi/newpipe/settings/DebugSettingsFragment.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import android.app.AlertDialog;
44
import android.content.DialogInterface;
55
import android.content.Intent;
6+
import android.content.SharedPreferences;
67
import android.os.Bundle;
78

89
import androidx.preference.Preference;
10+
import androidx.preference.PreferenceManager;
911

1012
import org.schabi.newpipe.R;
1113
import 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

Comments
 (0)