Getdefaultsharedpreferences(context) - Any Context?
I have a helper class for dealing with the default shared preferences. I retrieve the preferences once and I wrap all the SP methods I need, providing the same cached instance. It
Solution 1:
Use synchronization, but I would suggest using something like a ReentrantLock (http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReentrantLock.html) instead of "synchronized". It is generally more performant.
Any context will work, so long as it's not null of course. I would just use the application context here, which will save your callers from having to supply it. Expose a static reference to it, as seen here: Static way to get 'Context' on Android?
Post a Comment for "Getdefaultsharedpreferences(context) - Any Context?"