I have some shared preferences (latitude, longitude) that I want to access from a service, that is not subclassed from Activity.
In particular, when I try to access
Actually, most of you might be running into the problem, that on devices with API >=11, the shared preferences are not set for multi process use by default anymore.
Solution:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
prefs = getSharedPreferences(PREFS, 0 | Context.MODE_MULTI_PROCESS);
} else {
prefs = getSharedPreferences(PREFS, 0);
}