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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:09:02+00:00 2026-05-27T09:09:02+00:00

I want to share user config data from three separate Activities. What is the

  • 0

I want to share user config data from three separate Activities. What is the advantage/disadvantage
to one methodology over the other (using a single Prefs file or three)?

What I’m thinking is if I use one, I’ll declare the same const in the main Activity, a la:

public static final String PREFS_NAME = "Pterodactyl"; //Activity 1

and use getPreferences();

-OR:

I’ll declare a different const in each Activity, a la:

public static final String PREFS_NAME = "Pterodactyl";  //Activity 1
public static final String PREFS_NAME = "duckbilledPlatypus";  //Activity 2
public static final String PREFS_NAME = "yellowbelliedSapsucker";  //Activity 3

and use getSharedPreferences();

Is it “6 of one and half a dozen of the other” or is one of these “preferable” over the other, and why?

  • 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-27T09:09:02+00:00Added an answer on May 27, 2026 at 9:09 am

    Any Preference which is global and related to all activities would be in global file. Now how many files you should create depends on your taste mainly. As property files just contain name/value pair and no grouping so does not matter whether they are in one file or not.

    I recommend single global file for settings, it makes your life very easy. Use below api:

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    

    There is no file name involved it this. So you can live without having any preferences file names in your code.

    Regarding Activity specific file, use this when you have properties regarding Activity which you want to retain across sessions like you have scroll position to store so that when you back even after closing app you can restore it.

    For reference:

    http://developer.android.com/guide/topics/data/data-storage.html#pref

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

Sidebar

Related Questions

want to share a link from my application in windows phone 7. Any one
We want to share user validation configuration between a Java validation class (for sanity
I have a PHP page and I want to share some data between pages
I am writing an Titanium iPhone app when I want user to share his
I want to share data between threads, and have it automatically deleted when the
I want to share to facebook a link and allow the user to choose
I want to share an object between my servlets and my webservice (JAX-WS) by
I want to share an eclipse project with the rest of my team through
I want to share my experience of using maven through a proxy. You would
This is the URL I want to share: http://mydomain.com/#url=http://stackoverflow.com Inside my site, I do

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.