I have a settings menu in my app which controls the units used throughout the app – metric or US units. So when the user selects one of these in the options in the menu, I want my app to use the chosen units throughout in display and calculations.
I plan to do this by storing a boolean in sharedpreferences, then check the value of the boolean every time an activity is opened, and then make the appropriate changes.
Is there a better method to go about doing this?
Thanks
Yes you can extends Applications class and store your data over there using Getter and setter.
So that your data will be retained throughout the Application.
Access it in Activity like :
Add your Application to Maanifest file like this :
Edit :
You should add your class name that extends Application into Application Tag not on Activity Tag
For further refrence check this link