R
R
Ruslan Kolmakov2015-11-26 13:56:55
Android
Ruslan Kolmakov, 2015-11-26 13:56:55

How to erase all SharedPreferences?

The cleanup function looks like this, but nothing happens to you. The context here is obtained in the constructor via getApplicationContext()

fun clear() {
        val prefs = context.getSharedPreferences("MyAppPrefs", 0)
        var editor: SharedPreferences.Editor =  prefs.edit()
        editor.clear()
        editor.putBoolean("clear", true)
        editor.apply()
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Anatolyevich, 2015-11-26
@vitalyraevsky

editor.clear().commit();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question