Right now I can run the lines below to clear the preferences from within my application. But is there a way to do this outside my code? A command I can run from Eclipse or the emulator that can accomplish the same thing?
SharedPreferences settings = getSharedPreferences(PREF_FILE_NAME, 0);
Editor e = settings.edit();
e.clear();
e.commit();
As an alternative to using the shell, you can also delete the files from Eclipse by going into the DDMS
perspective, then choosing the File Browser
tab (on the top right panel by default) and navigating to /data/data/<packagename>/shared_prefs
and delete whichever preference files you want to by selecting them and pressing the red minus button at the top of the panel. (The red minus button doesn't work for entire folders. As far as I know, you have to use shell's rmdir
command to get rid of those.)
You can delete files from the settings on the device itself. Go to Settings --> Apps --> Your App --> Clear data.
(With 4.4 Kit Kat on a Nexus 7.)
Update:
For newer Android devices (8+) a faster way is: Long touch app icon --> Click App Info --> Click Storage --> Clear Data
Use the adb shell to remove the preferences xml file from your app. There are a bunch of other tricks you can do via the shell as well. You can also nuke the preferences file via the file explorer via the eclipse plugin. You should be able to find preferences under /data/data/<packagename>/preferences
or something like that (I don't have the path handy at the moment).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With