title: addPreferencesFromResource
body: <p>I know this might be a duplicate from: <a href="https://stackoverflow.com/questions/6822319/what-to-use-instead-of-addpreferencesfromresource-in-a-preferenceactivity">What to use instead of &quot;addPreferencesFromResource&quot; in a PreferenceActivity?</a></p>
  
  <p>But I still can not get the code to work and would appreciate some help. I can not get the:
  "addPreferencesFromResource(R.xml.preferences);" to work. </p>
  
  <p>preferences is not resolved, even though it is in the R.xml folder.</p>
  
  <p>I followed the example in the above link to the letter. </p>
  
  <p>Please help!!</p>
  
  <pre><code>package com.example.oasisreference;
  
  import android.R;
  import android.R.xml;
  //import android.annotation.TargetApi;
  import android.os.Bundle;
  import android.preference.PreferenceActivity;
  import android.preference.PreferenceFragment;
  
  public class Prefs extends PreferenceActivity  {
  
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      getFragmentManager().beginTransaction().replace(android.R.id.content, new   MyPreferenceFragment()).commit();
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public static class MyPreferenceFragment extends PreferenceFragment
  {
  @Override
  public void onCreate(final Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.preferences);
  }
  
  }
  
  }
  </code></pre>
  
  <p>preferences.xml in the Res.xml folder</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;EditTextPreference
      android:title="User Name"
      android:key="name"
      android:summary="Enter your name"
      &gt;&lt;/EditTextPreference&gt;
  &lt;CheckBoxPreference
      android:title="Euro Currency"
      android:defaultValue="false"
      android:key="euro"
      android:summary="Check for Use Cost Calculator to be in Euros/Liters"&gt;
   &lt;/CheckBoxPreference&gt;
  
  
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <p>menu.xml</p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  
  
  &lt;item
      android:id="@+id/aboutUs"
      android:title="About the Author"&gt;
  &lt;/item&gt;
  &lt;item
      android:id="@+id/preferences"
      android:title="Preferences"&gt;
  &lt;/item&gt;
  &lt;item 
      android:id="@+id/exit"
      android:title="Exit"&gt;
  &lt;/item&gt;
  
  &lt;/menu&gt;
  </code></pre>