title: How to get preferences from fragment
body: <p>i am wanna get string from my preferences file to fragment activity. for the other activity i use code like this:</p>
  <pre><code>        String fcmToken = Preferences.getFcmToken(getBaseContext());
  </code></pre>
  <p>but in the fragment activity i can not use that.
  here is my preferences code fill:</p>
  <pre><code>public class Preferences extends Application {
  
  static final String KEY_USER_TEREGISTER =&quot;user&quot;, KEY_PASS_TEREGISTER =&quot;pass&quot;;
  static final String KEY_USER_TOKEN = &quot;user_token&quot;;
  static final String KEY_FCM_TOKEN = &quot;fcm_token&quot;;
  
  public static SharedPreferences getSharedPreference(Context context){
      return PreferenceManager.getDefaultSharedPreferences(context);
  }
  
  public static void setRegisteredUser(Context context, String username){
      SharedPreferences.Editor editor = getSharedPreference(context).edit();
      editor.putString(KEY_USER_TEREGISTER, username);
      editor.apply();
  }
  
  public static String getRegisteredUser(Context context){
      return getSharedPreference(context).getString(KEY_USER_TEREGISTER,&quot;&quot;);
  }
  
  
  public static void setRegisteredPass(Context context, String password){
      SharedPreferences.Editor editor = getSharedPreference(context).edit();
      editor.putString(KEY_PASS_TEREGISTER, password);
      editor.apply();
  }
  
  public static String getRegisteredPass(Context context){
      return getSharedPreference(context).getString(KEY_PASS_TEREGISTER,&quot;&quot;);
  }
  
  public static void setUserToken(Context context, String token){
      SharedPreferences.Editor editor = getSharedPreference(context).edit();
      editor.putString(KEY_USER_TOKEN,token);
      editor.apply();
  }
  
  public static String getUserToken(Context context){
      return getSharedPreference(context).getString(KEY_USER_TOKEN, &quot;&quot;);
  }
  
  public static void setFcmToken(Context context, String token){
      SharedPreferences.Editor editor = getSharedPreference(context).edit();
      editor.putString(KEY_FCM_TOKEN,token);
      editor.apply();
  }
  
  public static String getFcmToken(Context context){
      return getSharedPreference(context).getString(KEY_FCM_TOKEN, &quot;&quot;);
  }
  
  public static void clearLoggedInUser (Context context){
      SharedPreferences.Editor editor = getSharedPreference(context).edit();
      editor.clear();
      editor.commit();
  }
  </code></pre>
  <p>}</p>
  <p>can you guys please how to do in fragment activity or my preferences code must to change?</p>