How do I delete SharedPreferences data for my application?
I\'m creating an application that uses a lot of web services to sync data. For testing purposes, I need to
Editor editor = getSharedPreferences("clear_cache", Context.MODE_PRIVATE).edit();
editor.clear();
editor.commit();
If it's not necessary to be removed every time, you can remove it manually from:
Settings -> Applications -> Manage applications -> (choose your app) -> Clear data or Uninstall
Newer versions of Android:
Settings -> Applications -> (choose your app) -> Storage -> Clear data and Clear cache
Try this code:
SharedPreferences sharedPreferences = getSharedPreferences("fake", Context.MODE_PRIVATE);
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.clear().commit();
String prefTag = "someTag";
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext);
prefs.edit().remove(prefTag).commit();
This will delete the saved shared preferences with the name "someTag".
You can also just manually uninstall your app using your device. Then when you re-install your app, shared preferences have been reset.
Clear them all:
PreferenceManager.getDefaultSharedPreferences(context).edit().clear().apply()