title: Android Retrofit Call pass response.body() as paramater for processing
body: <p>I'm wondering how to pass the response.body() as paramater in order to further process it.
  Since now i could pass it only to a Toast, or setText of a textView, and it works just fine.
  But if i try to pass it to a function which saves it to SharedPrefs or something like it just passes a null object. I don't get the point why the first is working, but the second not, where's the difference?</p>
  <p>My JSon response body looks like this:</p>
  <pre><code>{
      &quot;Authorization&quot;: &quot;Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbkBhZG1vbi5jb20iLCJleHAiOjE1OTQ2NTQ0NjF9.4meOycRP4wbx6hVCJntxH71E03jMYJhg484zCGInUDh6EKPPVDlOhEkCC3X2mjPaCHVfT0qhiulBnC39uh4WEQ&quot;
  }
  </code></pre>
  <p>My Pojo like this:</p>
  <pre><code>public class LoginResponse {
  
      @Expose
      @SerializedName(&quot;Authorization&quot;)
      private String authToken;
  
      public LoginResponse(String authToken) {
          this.authToken = authToken;
      }
  
  
      public void setAuthToken(String authToken) {
          this.authToken = authToken;
      }
  
      public String getAuthToken() {
          return authToken;
      }
  }
  </code></pre>
  <p>The function where I do the Call (it's called after hitting the login button):</p>
  <pre><code>private void loginCustomer() {
          LoginRequest loginRequest = new LoginRequest(editTextUsername.getText().toString(), editTextPassword.getText().toString());
  
          Call&lt;LoginResponse&gt; loginCall = ApiUtils.getApi().login(loginRequest);
          loginCall.enqueue(new Callback&lt;LoginResponse&gt;() {
              @Override
              public void onResponse(@NotNull Call&lt;LoginResponse&gt; call, @NotNull Response&lt;LoginResponse&gt; response) {
                  if (!response.isSuccessful()) {
                      Toast.makeText(LoginActivity.this, &quot;User Credentials Wrong&quot;, Toast.LENGTH_SHORT).show();
                  } else {
                      if (response.body() != null) {
  
  // this does not work
                          authToken = response.body().getAuthToken();
                          saveToken(authToken);
  
   //this does not work either                       SharedPreferences.Editor editor = sp.edit();
                          editor.putString(&quot;authToken&quot;, response.body().getAuthToken());
  
  //                        openUserMainActivity();
  // this works                        Toast.makeText(LoginActivity.this, response.code() + &quot; &quot; + response.body().getAuthToken(), Toast.LENGTH_SHORT).show();
  // this does not work                        Toast.makeText(LoginActivity.this, sp.getString(&quot;authToken&quot;, &quot;no token&quot;), Toast.LENGTH_SHORT).show();
  
                      }
  
  
                  }
              }
  </code></pre>
  <p>Any help will be appreciated. Thanks in Advance!</p>