Página de configuración de Android

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?

Muchas Gracias

preguntado el 01 de febrero de 12 a las 03:02

Please clarify if you want settings for YOUR app or something else. -

The settings are for my app. As the first sentence says "for my Android app" -

1 Respuestas

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 ¿Por qué 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:

La clase SharedPreferences proporciona un marco general que le permite guardar y recuperar pares clave-valor persistentes de tipos de datos primitivos. Puede usar SharedPreferences para guardar cualquier dato primitivo: booleanos, flotantes, ints, longs y strings. Estos datos persistirán en las sesiones de los usuarios (incluso si se mata su aplicación).

By primitives, it means lightweight variables that can be stored/committed.

Respondido 01 Feb 12, 07:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.