reading preference value
<p>i am working on android and trying to read a value from my preference file.
but when i run.a message appears in emulator.the
<strong>the application has stopped unexpectedly</strong>
here is my preference file name pref.and it is inres/xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt;
        &lt;CheckBoxPreference android:defaultValue="false"
             android:key="@string/first"/&gt;
    &lt;/PreferenceScreen&gt;
</code></pre>

<p>this is main activity where i am reding the value.</p>

<pre><code>package code.finalwork;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.EditText;

public class FinalWorkActivity extends Activity {
    private String pref_file="pref.xml";
EditText text=(EditText) findViewById(R.id.editText1);
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        SharedPreferences pref=getSharedPreferences(pref_file,Context.MODE_PRIVATE);
       Boolean val= pref.getBoolean("firstuse", true);
       if(val)
       {
            text.setText("first use");
       }
       else
       {
           text.setText("Not first use");
       }


    }
}
</code></pre>

<p>please someone figure out the problem.</p>
