开发者

deleting sharedPreferences in android

开发者 https://www.devze.com 2023-03-22 05:59 出处:网络
I want to delete the various information i have stored as shared preferences. I know i can do开发者_如何学C it using remove(),but i m not getting where actually i should use it.

I want to delete the various information i have stored as shared preferences. I know i can do开发者_如何学C 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.


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


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号