title: Accessing SharedPreferences through static methods
body: <p>I have some information stored as SharedPreferences. I need to access that information from outsite an Activity (in from a domain model class). So I created a static method in an Activity which I only use to get the shared preferences. </p>
  
  <p>This is giving me some problems, since apparently it is not possible to call the method "getSharedPreferences" from a static method.</p>
  
  <p>Here's the message eclipse is giving me:</p>
  
  <pre><code>Cannot make a static reference to the non-static method 
  getSharedPreferences(String, int) from the type ContextWrapper
  </code></pre>
  
  <p>I tried to work around this by using an Activity instance, like this:</p>
  
  <pre><code>public static SharedPreferences getSharedPreferences () {
    Activity act = new Activity();
    return act.getSharedPreferences("FILE", 0);
  }
  </code></pre>
  
  <p>This code gives a null point exception.</p>
  
  <p>Is there a work-around? Am I going into an android-code-smell by trying to do this?</p>
  
  <p>Thanks in advance.</p>