Delete All Android Application SharedPreferences

-1

I'm in the middle of a development of an ANDROID application, which contains a lot of Activity and for each Activity there are some checkBox and I'm using SharedPreferences to save what was selected in case the user wants to return to the screen. But I need to delete all SharedPreferences when I start the application. How can I do this?

    
asked by anonymous 05.04.2014 / 22:21

2 answers

2

Do this:

SharedPreferences.Editor prefsEditor = getSharedPreferences(arquivo, 0).edit();
prefsEditor.clear();
prefsEditor.commit();

This will remove all saved values.

    
05.04.2014 / 23:56
0

I did it this way:

public void deletarSharedPreferences()
    {
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.clear();
        editor.commit();
    }
    
07.04.2014 / 03:57