title: What's the difference between getDefaultSharedPreferences() and getPreferences()?
body: <p>I'm currently taking the "Developing Android Apps" Udacity course. In the "Lesson 3: New Activities and Intents >  Use SharedPreferences" segment, the instructor asked me to dig around the Android Developer site for how to get the user preferences from <code>SharedPreferences</code>. However, I found it different between the official documentation and the course's solution.</p>
  
  <p>The Udacity course's <a href="https://www.youtube.com/watch?v=yynDxu43pSM" rel="noreferrer">solution</a> says, to grab a <code>SharedPreferences</code> instance for the <code>PreferenceActivity</code>, you should call:</p>
  
  <pre><code>SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
  </code></pre>
  
  <p>(where <code>getActivity()</code> is simply the <code>Context</code> here because it's called inside a <code>Fragment</code>.)</p>
  
  <p>While <a href="http://developer.android.com/guide/topics/data/data-storage.html#pref" rel="noreferrer">the official documentation</a> on Android Developer Site indicates that you should call:</p>
  
  <pre><code>SharedPreferences prefs = getActivity().getPreferences(Context.MODE_PRIVATE)
  </code></pre>
  
  <p>So what's the difference between <code>PreferenceManager.getDefaultSharedPreferences(Context context)</code> and <code>Activity.getPreferences(int mode)</code>?</p>
  
  <p><strong>Please note:</strong> This question does not involve anything about <code>getSharedPreferences()</code> which requires a file name. It's about the difference between <code>getPreferences()</code> and <code>getDefaultSharedPreferences()</code>.</p>
  
  <p>Thanks in advance.</p>