title: Android Crash after using SharedPreferences
body: <p>I am developing an Android Application, for keep me logged in functionality I am using SharedPreferences application started to crash.</p>
  
  <p>This is the line that i add for Preferences;</p>
  
  <pre><code>SharedPreferences pref = getApplicationContext().getSharedPreferences("RS_Remember" , getApplicationContext().MODE_PRIVATE);
  </code></pre>
  
  <p>I am pretty sure that this line is causing error because it works fine if i remove it.</p>
  
  <p>Error message i get says:</p>
  
  <p>java.lang.Runtime: Unable to create application com.x.x.x : java.lang.NullPointerException.</p>
  
  <p>Any idea abot what i shuold do?</p>
  
  <p><strong>Edit</strong></p>
  
  <pre><code>public Activity activity;
      SharedPreferences pref;
      private RSCurrentUserManager()
      {
          super();
  
              pref = this.activity.getSharedPreferences("RallySpark_Remember",0);
  
  
      }
  
  
  +05-09 18:02:56.221: E/AndroidRuntime(31760): FATAL EXCEPTION: main
  +05-09 18:02:56.221: E/AndroidRuntime(31760):
   java.lang.RuntimeException: Unable to create application
   com.x.x.general.RSApplication:
   java.lang.NullPointerException
  +05-09 18:02:56.221:
   E/AndroidRuntime(31760):   at
   com.x.x.general.RSCurrentUserManager.&lt;init&gt;(RSCurrentUserManager.java:93)
  +05-09 18:02:56.221: E/AndroidRuntime(31760):   at com.x.x.general.RSCurrentUserManager.getInstance(RSCurrentUserManager.java:84)
  </code></pre>
  
  <p>I am not using Shared preferences in any other pleace in order to find the problem i removed everything execpt its defination</p>