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

  • SEARCH
  • Home
  • 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 7947759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:31:31+00:00 2026-06-04T01:31:31+00:00

I have an application which has a Prefernces Class and I want to know

  • 0

I have an application which has a Prefernces Class and I want to know how could i make so that when the application is started the settings to be applied even before entering the preferences ( settings ) class. I have a getPrefs() void method which is called when i press “Save” Button in preference activity.

So, could you help me and tell what should I do the “default” preferences to be applied when entering the application ? (I need getprefs method from another class )

I would be grate if you could give me some advices or tips.Thank you !

  • 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-04T01:31:32+00:00Added an answer on June 4, 2026 at 1:31 am

    To get an instance of the SharedPreferences from anywhere in your application use:

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPrefences(context);
    

    To set a value in the preferences, you need to call the editor for those preferences, then set the value for a key and finally commit the result. It can all be done in a single line:

    prefs.edit().putString("myKey","myValue").commit();
    

    This would store the string value myValue on a key named myKey and it will be accessible (after you commit) to any class if it has the application’s context when it calls getDefaultSharedPreferences.

    To retrieve the stored value you specify the key and a fallback value in case there is no preference set with that key:

    prefs.getString("myKey","oops no value found");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which has a similar interface to Visual Studio, in that
I have an application which has some classes that handle some specific functions, have
I have an application which has a Projects table and a Users table. In
We have an application which has about 15000 pages. For better SEO reasons we
I have an MVC application which has a set of fields for contact details
I have an iphone application which has about 4 tabs. How do I force
I have a Windows application which has a browser in it. The Windows application
I have a Java Application which has to load an DLL with a few
We have a Flex application which has several 'pages' worth of content. Each time
I have a console application which has target .NET 2.0 It is very short

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.