Now you can Subscribe using RSS

Submit your Email

Saturday

How to reset Shared Preferences.

Vishal Shrestha
If you are a developer and want to clear your app's shared preferences just for testing purposes then you can simply go to your app's setting and clear data.
If you want a reset setting in your app for your user then you can use the following methods-

1. To remove all preferences-
SharedPreferences settings = context.getSharedPreferences("YourPreferencesName", Context.MODE_PRIVATE);
settings.edit().clear().commit();

2. To remove a particular value-


SharedPreferences settings = context.getSharedPreferences("YourPreferencesName", Context.MODE_PRIVATE);
settings.edit().remove("Key").commit();

You can learn more here.

Vishal Shrestha / Author & Founder

A developer by profession, a born Adventurer. I mainly do Android but like to get my hands dirty with web development and a little bit of Python. I would't rather go on a Trek than a party and you can find me having a few rounds with the heavy bag to let out the steam ;)

For Business info : My Portfolio Site.

0 comments:

Post a Comment

Coprights @ 2017 | The Code City by Vishal Shrestha Vishal Shrestha