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 6062671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:04:44+00:00 2026-05-23T09:04:44+00:00

I have multiple views that come and go as the application runs. I want

  • 0

I have multiple views that come and go as the application runs. I want each view to have its own personal preferences that are stored as the ID tag of the view. Above these is the “General Preferences” that the sub prefs reference to get their default values when a view it is created.

Right now I have it set up that the General Preferences are the default SharedPreferences. But I have no Idea how to create the new preferences and set up an activity UI so the user can change them. Is it pretty much the same as setting up the SharedPreferences?

  • 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-05-23T09:04:44+00:00Added an answer on May 23, 2026 at 9:04 am

    this may not be exactly what you’re asking for, but here’s what I do:

    in my main activity, when I call the preferences activity, I pass it the name of the custom preference file as extra data in the intent:

    static final String EXTRA_PREFERENCES_NAME = "android.intent.extra.PREFERENCES_NAME";
    ...
    Intent intent = new Intent(this, Preferences.class);
    intent.putExtra(EXTRA_PREFERENCES_NAME, preferencesName);
    startActivity(intent);
    

    then, in my preferences activity, I get the custom preferences name and set it like this:

    public class Preferences extends PreferenceActivity {
        private String preferencesName = "";
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        // get the custom preferences name from the extra data in the intent
        preferencesName = getIntent().getExtras().getString(MainActivity.EXTRA_PREFERENCES_NAME);
        // set the preferences file name
        getPreferenceManager().setSharedPreferencesName(preferencesName);
        // get the default preferences from XML
        addPreferencesFromResource(R.xml.preferences);
    }
    

    lastly, in my main activity, I get specific preferences like this:

    SharedPreferences preferences = getSharedPreferences(preferencesName, MODE_PRIVATE);
    String somePreference = preferences.getString("somePreference", defaultValue);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view that has multiple views inside it, and an image presentation
I have a MVVM application that contains multiple views with some complex IsReadOnly rules
In my iPad Application I have multiple views on a screen. What I want
I have created an application with multiple views. I have my main view (ViewController.h)
I have a fairly complex view that has multiple forms, lots of validations on
I have a for loop that creates multiple UIImageViews that I add to self.view
Is it considered bad practice to have multiple views for same URL in MVC,
I have a very large script which is creating multiple views. In a number
I am have an issue with my scrollview which holds multiple views. I think
I have used multiple activities to handle mutiple views in android . I found

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.