title: Call fragment method from dialogfragment
body: <p>I'm trying to call <code>fragment</code> function from <code>dialogfragment</code>. My application is based on <code>navigation drawer</code> which contains container for <code>fragments</code>. At one of my <code>fragments</code> I make <code>retrofit</code> request and I also can open <code>dialogfragment</code>  from this <code>fragment</code>. But I faced with one very serious problem - I can't get <code>SharedPreferences</code> after calling fragment function from <code>dialogFragment</code>. Here how I call this method:</p>
  
  <pre><code> btn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  dismiss();
                  JobList jobList = new JobList();
                  jobList.testFunction();
              }
          });
  </code></pre>
  
  <p>and here is my <code>testFunction()</code>:</p>
  
  <pre><code>public void testFunction() {
          sp = Objects.requireNonNull(getActivity()).getSharedPreferences("app_data", 0);
          Log.w("MY_tag", sp.getString("access_token", ""));
      }
  </code></pre>
  
  <p>my testFunction contains only experimental logs, because I try to get data from sharedpreferences but I get only error:</p>
  
  <blockquote>
    <p>java.lang.NullPointerException</p>
  </blockquote>
  
  <p>after putting breakpoint I understood that I can't receive any context for getting sharedPreferences. I can't understand how to solve my problem, and I will be happy if smb help me with the solution. </p>