title: android Sharedpreferences non-activity class
body: <pre><code>private static String geturl() {
          Context applicationContext = configActivity.getContextOfApplication();
  //        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext);
  
          SharedPreferences prefs =applicationContext.getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
          String url = prefs.getString(&quot;url&quot;, &quot;No name defined&quot;);
          return url;
      }
  </code></pre>
  <p>This method is in a non-activity class
  i tried to have my string from a non-activity class
  i tried to do like someone say there :<a href="https://stackoverflow.com/questions/7491287/android-how-to-use-sharedpreferences-in-non-activity-class">Android - How to use SharedPreferences in non-Activity class?</a></p>
  <p>but i have this error :</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>