Android PreferenceManager without visual component?
I am trying to get a SharedPreferences object from the PreferenceManager but don't want t开发者_如何学Goo pass in the Context to the class.
Can I get a "global" context from inside my class?
SharedPreferences pref =
PreferenceManager.getDefaultSharedPreferences(Some Global Context);
You should generally have a reference to a context from any major component of your application (Activity, Service, etc...) If this is a utility class then passing a reference of a context should suffice.
Is there a particular pattern you are trying to implement.. or avoid implementing?
精彩评论