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?
Asked
Active
Viewed 1,327 times
4 Answers
0
context.getSharedPreferences("PREF", 0).edit().clear().commit();

Ashton
- 174
- 11
-
1Please add some more context to this answer so the OP understands the solution. E.g. "What are the 'PREF' and '0' arguments?" – Roel Strolenberg Sep 10 '18 at 11:57
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