Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7956885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:07:38+00:00 2026-06-04T04:07:38+00:00

I have a settings menu in my app which controls the units used throughout

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:07:40+00:00Added an answer on June 4, 2026 at 4:07 am

    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.

    public class SocketManager extends Application {
    private static SocketManager singleton;
    public int mBluetoothState;
    
    
    public synchronized static SocketManager getInstance(Context context) {
        if (null == singleton) {
            singleton = new SocketManager();
        }
        return singleton;
    }
    
    public synchronized void setState(int state) {
        mBluetoothState = state;
    }
    
    public synchronized int getState() {
        return mBluetoothState;
    }
    }
    

    Access it in Activity like :

      SocketManager socketManager = SocketManager.getInstance(this);
      socketManager.setState(10);
      socketManager.getState();
    

    Add your Application to Maanifest file like this :

     <application
      android:name=".SocketManager"
      android:icon="@drawable/first_aid"
      android:label="@string/app_name" >
    
       <activity .... />
    
     </application>
    

    Edit :

    You should add your class name that extends Application into Application Tag not on Activity Tag

    For further refrence check this link

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my app I have an option menu in which the user can change
When I click Settings in my application's menu, app crash instantly. I don't have
I have some settings in my app.config which I intend to be 'global' -
I have this view which generates interface language options menu def lang_menu(request,language): lang_choices =
I'm an Android newbie, and working on an app which needs an Options menu.
I have a ClickOnce environment like this: \\Fileserver\ClickOnceApps\App1.application C:\Documents and Settings\user\Start Menu\Programs\publisher\app1.appref-ms My understanding
I have menu in my App. I need to check for the which menu
I have a settings menu that pops up and in it is a ListPreference
I have this menu: <h:selectOneMenu value=#{ApplicationController.settings['SessionTTL']}> <f:selectItem itemValue=60 itemLabel=1 hour /> <f:selectItem itemValue=30 itemLabel=30
I have settings dialog with a number of ComboBoxes. More often than not, these

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.