You can access the default shared preferences instance, which is shared across all your Activity
and Service
classes, by calling PreferenceManager.getDefaultSharedPreferences(Context context)
:
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
This is great for storing simple primitives (like booleans) or serializable objects. However, if you’re capturing a lot of location data, you might consider using a SQLite database instead.