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

The Archive Base Latest Questions

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

I am looking an android Shared Preferences and I am wondering is there a

  • 0

I am looking an android Shared Preferences and I am wondering is there a way to just check if the preferences file exists.

   SharedPreferences  mySharedPreferences ; 
mySharedPreferences=getSharedPreferences(“Name_of_your_preference”,mode);

This above code leads me to believe that “Name_of_Your_preferene” is stored as a file or some sort of container that will contain your preferences.

I am wondering is there away to check if this exists or not. When a user loads up an activity I want to save all the settings into this file with some default values(off for all settings). However I only want to do this if they are going to the page for the first time.

Otherwise if I would do something like this every time the page loads up

SharedPreferences.Editor editor= mySharedPreferences.edit();

/* now store your primitive type values. In this case it is true, 1f and Hello! World  */

editor.putBolean(“myBoolean”,true);

editor.putFloat(“myFloat”,1f);

editor.putString(“myString”,” Hello! World”);

I am guessing it would override all settings even ones they set.

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

    The SharedPreferences are saved in a xml file. You can find it in /data/data/your_application_package/shared_prefs/Name_of_your_preference.xml

    To check if the SharedPreferences ‘Name_of_your_preference’ exist :

    File f = new File(
    "/data/data/your_application_package/shared_prefs/Name_of_your_preference.xml");
    if (f.exists())
        Log.d("TAG", "SharedPreferences Name_of_your_preference : exist");
    else
        Log.d("TAG", "Setup default preferences");
    

    Regards.

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

Sidebar

Related Questions

I just started looking at the android framework and was wondering what was the
I m currently looking into android notification. Is there any way to show all
Looking in the android sdk folders, I've found a file called values/config.xml . This
HI all, I'm just getting started with developing for Android. I'm looking to port
I'am looking for this file to work with Android ADK Demo. This Link INSTALL_FAILED_MISSING_SHARED_LIBRARY
I'm looking for android sniffer projects... Is there any sniffers for Android like Kismet
Is there anything like the Android's Share button in iPhone? I am just starting
I've been looking for a way to create a 3d-shaded button in Android. That
Is there any way within the Android Marketplace to share sales statistics of any/all
I'm looking at the Android Camera code, and when I try importing android.os.SystemProperties ,

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.