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
  • 34,719
  • 24
  • 185
  • 251

4 Answers4

0

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

Andriy Klitsuk
  • 553
  • 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,382
  • 2
  • 13
  • 28
0

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

droidev
  • 7,104
  • 11
  • 60
  • 93