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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:00:19+00:00 2026-05-22T21:00:19+00:00

When the application is first startet, I’d like to store all default values I’ve

  • 0

When the application is first startet, I’d like to store all default values I’ve defined in my prefences.xml by using the ‘android:defaultValue’ attribute, but some of them are not stored on the device – can someone tell me why?

<?xml version="1.0" encoding="utf-8"?>

<PreferenceCategory android:title="@string/prefs_cat_title_x">
    <ListPreference
        android:key="@string/prefs_key_1"
        android:title="@string/prefs_title_1"
        android:summary="@string/prefs_summary_1"
        android:entries="@array/array1"
        android:entryValues="@array/array1"
        android:defaultValue="@string/prefs_default_1"/>
    <com.myapp.TimePreference
        android:key="@string/prefs_key_2"
        android:title="@string/prefs_title_2"
        android:defaultValue="@string/prefs_default_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <com.myapp.TimePreference
        android:key="@string/prefs_key_3"
        android:title="@string/prefs_title_3"
        android:defaultValue="@string/prefs_default_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <ListPreference
        android:key="@string/prefs_key_4"
        android:title="@string/prefs_title_4"
        android:summary="@string/prefs_summary_4"
        android:entries="@array/array2"
        android:entryValues="@array/array2"
        android:defaultValue="@string/prefs_default_4"/>
    <CheckBoxPreference
        android:key="@string/prefs_key_5"
        android:title="@string/prefs_title_5"
        android:summary="@string/prefs_summary_5"
        android:defaultValue="false"/>
    <CheckBoxPreference
        android:key="@string/prefs_key_6"
        android:title="@string/prefs_title_6"
        android:summary="@string/prefs_summary_6"
        android:defaultValue="false"/>
</PreferenceCategory>

<PreferenceCategory android:title="@string/prefs_cat_title_common">
    <com.myapp.DatabaseResetPreference
        android:title="@string/prefs_title_7"
        android:summary="@string/prefs_summary_7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</PreferenceCategory>    

  • 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-22T21:00:20+00:00Added an answer on May 22, 2026 at 9:00 pm

    I’ve found a solution to my problem, but it still doesn’t answer my question.
    I had to change the line:

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    

    into:

    PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
    

    As the docs say, setting readAgain should not overwrite any existing preference values:

    “Note: this will NOT reset preferences
    back to their default values.”

    Simply using “true” works for me, but I still don’t know why only the defaults for three of my preferences are set when using “false”, even though the xml file containing KEY_HAS_SET_DEFAULT_VALUES didn’t exist (and so wasn’t set to true) on the device (it existed not until I called the method above).

    If anyone knows a possible reason for that behavior, please let me know!

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

Sidebar

Related Questions

First some background: VB.NET 2005 Application that accesses a MS-SQL back-end, using multiple Web
I am pretty far into my first Android application, and I have the sneaking
I'm looking for a good ORM for my android application and at first glance
I'm currently developing my first android application. I want the user of my application
I need to add initial values to SQLite database, once application is started first
I am writing a quick application myself - first project, however I am trying
I'm about to build my first Ruby on Rails application (and first anything beyond
I'm new to iPhone and Apple development and working on my first application. It
I'm a newbie Cocoa developer and I'm developing my first application. I want to
Writing my first Linq application, and I'm trying to find the best way to

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.