Boon
Boon

Reputation: 41510

What is context in PreferenceManager.getDefaultSharedPreferences used for?

Given that any non-null context passed to PreferenceManager.getDefaultSharedPreferences will return the same result, what is context used for by PreferenceManager and what's the point of passing in different context?

Upvotes: 1

Views: 672

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007544

what is context used for by PreferenceManager

To get at the locations of internal storage and, IIRC, the package name of the app.

what's the point of passing in different context?

In general, any Context will do for this method call. In principle, you could pass in some ContextWrapper that overrides something that would be used by getDefaultSharedPreferences().

Upvotes: 3

Related Questions