title: How to getSharedPreferences in Application?
body: <p>I tried to call <code>getSharedPreferences</code> in Application...</p>
  
  <pre><code>public class App extends Application{
      public App() {
          SharedPreferences prefs = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
      }
  }
  </code></pre>
  
  <p>...but I got a <code>NullPointerException</code>:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method
    'android.content.SharedPreferences
    android.content.Context.getSharedPreferences(java.lang.String, int)' 
    on a null object reference
  </code></pre>
  
  <p>I also tried this and got same exception:</p>
  
  <pre><code>Context con = getApplicationContext();
  </code></pre>
  
  <p>How can I call <code>getSharedPreferences</code>?</p>