So this is the situation. I have created a simple google map in android. I have created another Activity (Settings.class) for Map settings. It has toggle buttons for customization of the app (notification "on/off", vibrate "on/off", sounds "on/off"). I want to use the values of these buttons to customize the map and the whole app, but every time I close/call another activity, the values were not retained. Can you help me what approach should I use?
Asked
Active
Viewed 304 times
0
-
1Use http://developer.android.com/reference/android/preference/PreferenceActivity.html. Here is a good tutorial about this http://viralpatel.net/blogs/android-preferences-activity-example/ – Hiren Dabhi Oct 07 '15 at 05:30
-
Yeah shared preference – DJphy Oct 07 '15 at 05:48
1 Answers
0
Those values are getting lost
That's because the activity has been destroyed when you close it. Either you could save it in a file/SharePreferences/sqlite storage and restore them when your activity is shown again.
Please read here about all these methods to store the values.
A Small Suggestion
You can also use a Preference Activity , for it will help you get the state changes in your toggle buttons. You can read about it here.

Community
- 1
- 1

cafebabe1991
- 4,928
- 2
- 34
- 42