SharedPreferences -- Where do the intial values come from with a new app?
<p>I've been looking into using preferences with an app that I have created.  For example:</p>

<p>One part of my app requires a CountDown timer.  The default for this count down timer should be 8:00 (8 minutes or 480000 ms).  However, I need the user to have the ability to change this to any value they want.</p>

<p>During my research, I have discovered the SharedPreferences ability built into Android but I'm a little confused how it works.</p>

<p>My thought was that the app will look for the shared preferences and if they aren't there use the defaults.  It doesn't seem to be working.  Once I install the new app (there currently isn't a Shared Preferences XML file, so I thought it would just load the defaults but I'm getting a null pointer error and the app crashes.</p>

<p>Here is my relevant code:</p>

<pre><code>long
    msSavedMainClock = 0,
    msSavedShotClock = 0,
    msShotClockStart,
    msMainClockStart;

TextView 
    tvPeriodPrefix,
    tvPeriod;

// Create the SharedPreferences object
SharedPreferences prefs = getSharedPreferences("settings", MODE_PRIVATE);

// Create the Preference Editor object
SharedPreferences.Editor prefsEditor = prefs.edit();

@Override
protected void onCreate(Bundle savedInstanceState) {

    /*******  more code here  *******/

    // Load the values/defaults from the SharedPreferences
    tvPeriodPrefix.setText( prefs.getString("Period_Prefix", getResources().getString(R.string.period)) );
    msMainClockStart = prefs.getLong( "Default_Main_Clock", 480000);    // 8 minute default
    msShotClockStart = prefs.getLong( "Default_Shot_Clock", 24000);     // 24 second default

    // Initialize other variables
    tvPeriod.setText( tvPeriodPrefix + "1" );

    /******* rest of my code here *******/
</code></pre>

<p>Can anyone tell me what I'm doing wrong please?</p>
