I’m using a public static object to handle user settings. The first view reads settings from Android database and creates the settings object. After this all my classes are able to use the settings.
However user may open another view and then kill the app. When the app is re-opened the first view will not be created and the setting object will be null.
There are some stuff that I have came up with but none seems very elegant to me.
Now I could just pass the settings object to all views but this will need to be repeated a lot and if the settings somehow change this would fail.
Each view could load the settings again. Probably the best solution but it generates a lot of seemingly stupid database connections and transactions.
There is something called SharedPreferences which seems to be exactly for sharing preferences between views. However it’s not documented anywhere does it solve the problem that I’m having.
Not documented? You can find an example in the android documentation : http://developer.android.com/guide/topics/data/data-storage.html#pref
It’s also very easy to find some tutorials on google.