title: Android SharedPreferences in Fragment
body: <p>I am trying to read SharedPreferences inside Fragment. My code is what I use to get preferences in any other Activity.</p>
  
  <pre><code>     SharedPreferences preferences = getSharedPreferences("pref", 0);
  </code></pre>
  
  <p>I get error </p>
  
  <pre><code>    Cannot make a static reference to the non-static method getSharedPreferences(String, int) from the type ContextWrapper    
  </code></pre>
  
  <p>I have tried to follow these links but with no luck <a href="https://stackoverflow.com/questions/3806051/accessing-sharedpreferences-through-static-methods">Accessing SharedPreferences through static methods</a> and 
  <a href="https://stackoverflow.com/questions/6241340/static-sharedpreferences">Static SharedPreferences</a>. Thank you for any solution.</p>