title: Read Firebase token in Fragment or Activity
body: <p>I have implemented Firebase using <a href="https://github.com/firebase/quickstart-android/blob/master/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/MyFirebaseInstanceIDService.java" rel="nofollow">this code</a> and I'm able to see the refresh token in logcat.</p>
  
  <p>I am trying to store the token so that I can use it in a Fragment</p>
  
  <pre><code>private void sendRegistrationToServer(String token) {
   PreferenceManager.getDefaultSharedPreferences(getBaseContext()).edit().putString("regToken", token).commit();  
  }
  </code></pre>
  
  <p>When I try to read it in my Fragment, where I will send the token to a server, I'm unable to read it:</p>
  
  <pre><code>PreferenceManager.getDefaultSharedPreferences(context).getString("regToken", "false"); 
  </code></pre>
  
  <p>Unfortunately, it fails to read <code>regToken</code> and returns <code>false</code> once the Fragment is invoked.</p>
  
  <p>How can I read the stored value from MyFirebaseInstanceIDService in my Fragment? I suspect the issue is with "different context's". If so, how can I use "the same" context when storing/reading.</p>