0

I'm creating an application in which I have used shared preferences, for testing purpose I have to swipe out that data (preferences) so, how could I clear shared preferences in Android programmatically?

Cœur
  • 37,241
  • 25
  • 195
  • 267

4 Answers4

0

Just do a SharedPreferences.Editor.clear() followed by a commit()

Andriy Klitsuk
  • 564
  • 3
  • 14
0
context.getSharedPreferences("PREF", 0).edit().clear().commit();
Ashton
  • 174
  • 11
0

Try this

SharedPreferences preferences = getSharedPreferences("PREFERENCE",Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.clear(); 
editor.commit();
Sniffer
  • 1,495
  • 2
  • 14
  • 30
0

To clear the preferences SharedPreferences.Editor.clear().apply() Check the same question answered here.

droidev
  • 7,352
  • 11
  • 62
  • 94