I’m working on building out a settings page for my Android app. For this I am using the PreferenceActivity and its functionality. The saving/editing of the settings is the simple part but I’m wondering what the best way to access the settings through the app is? I could of course access the SharedPrefs every time I need to, however, this seems inefficient to me…especially if since some of the settings could be access fairly frequently.
I’m wondering if it is worth creating a class that loads all of the settings when the app is opened and is then accessible through out the app via the Application class. This class would then be updated every time the settings are changed.
Is it worth taking this approach or is there a better way? Or is it not worth keeping the settings in memory throughout the lifetime of the app?
Thanks
The entire purpose for SharedPreference is what this is designed for. They are efficient to save/change the settings of your app, by just retrieveing it through your context. I dont see WHY you would keep it in memory, but you’d keep it in the XML key/value pairs that are SharedPrefereces.
Just use it, its what the android engineers would want you to do.
Just a snippet from the SDK:
By primitives, it means lightweight variables that can be stored/committed.