ssantos
ssantos

Reputation: 16526

Android 2.3 Resetting app preferences

I need to reset an installed app shared preferences from android settings, without loosing the rest of the app data stored in sqlite. Just found this.-

http://www.tech-recipes.com/rx/29473/ok-android-jelly-bean-reset-app-preferences/

but sadly it seems there's no direct option in Android 2.3.

Anyone knows a workaround for clearing app preferences for Android 2.3?

EDIT

I don't have access to the devices where the app is currently installed, no chance for rooting, nor can update the app code. I'm looking for a way to clear preferences from android menu.

EDIT 2

Just found the option Clear defaults inside manage apps settings, but it seems disabled for all my apps with message No defaults set.; aren't these defaults the ones stored in SharedPreferences?

Upvotes: 0

Views: 1424

Answers (2)

sider
sider

Reputation: 687

You could connect your phone to the PC, delete your preferences file from data/data/com.*./. In order to do that, you need root.

Upvotes: 2

tyczj
tyczj

Reputation: 73741

you can just loop through all your SharedPreferences and look for the keys you want to reset

SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
Map<String,?> prefs = pref.getAll();
for(Map.Entry<String,?> prefToReset : prefs.entrySet()){
    edit.remove(prefToReset.getKey()).commit();
}

Upvotes: 3

Related Questions