Is there a way to make SharedPreferences global throughout my whole Android app?

Viewed 18168

Is there a way to make SharedPreferences global throughout my whole app? Right now I'm using these lines in a lot of places throughout my code to store simple on/off settings for a number of preferences that my users can set. I just want to call them once globally if possible:

SharedPreferences settings = getSharedPreferences("prefs", 0);
SharedPreferences.Editor editor = settings.edit();

Any tips on how to be able to call just these line in all classes would be awesome:

editor.putString("examplesetting", "off");
editor.commit(); 

and

String checkedSetting = settings.getString("examplesetting", "");
4 Answers
Related