How to delete shared preferences data from App in Android

Andrew picture Andrew · Sep 10, 2010 · Viewed 399.4k times · Source

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 wipe out some SharedPreferences values when I restart the app.

Answer

Mark B picture Mark B · Sep 10, 2010

To remove specific values: SharedPreferences.Editor.remove() followed by a commit()

To remove them all SharedPreferences.Editor.clear() followed by a commit()

If you don't care about the return value and you're using this from your application's main thread, consider using apply() instead.