Kishan
Kishan

Reputation: 424

deleting sharedPreferences in android

I want to delete the various information i have stored as shared preferences. I know i can do it using remove(), but i m not getting where actually i should use it.

Can anyone tell me where actually i should remove() or clear() with a small code snippet...?

I used the following code to save data.

Editor editor = settings.edit();
editor.putString(PREFERENCES_PASS,pwd);
editor.commit();

here, pwd is a String that i extracted from EditText.

Upvotes: 1

Views: 800

Answers (2)

Suchi
Suchi

Reputation: 10039

Editor editor = settings.edit();
editor.remove(PREFERENCES_PASS);
editor.commit();

Upvotes: 1

Thomas Dignan
Thomas Dignan

Reputation: 7102

You can put it anywhere between your calls to obtain the editor, and calling commit().. So with your code example, you'd put it...

Editor editor = settings.edit();
editor.remove(PREFERENCES_PASS);
editor.commit();

See this doc

Upvotes: 3

Related Questions