title: Call Activity Method From Fragment
body: <p>I'm dealing with fragments.<br>
  I have an <code>Activity</code> and different <code>fragments</code>.<br>
  Each <code>fragment</code> need the access to a <code>Class(call it X)</code> that allow it to access a database, but, because I have a lot of fragments, I don't want to create a different instance of the <code>Class X</code> in every fragment as I think it will require lots of <code>memory</code>.<br>
  So how can I do?<br>
  I wrote something like this (with a getter), but it doesn't work!  </p>
  
  <pre><code>public class MyActivity {
    private ClassX classx;
  
    .....
  
    public ClassX getClassX() {
       return classx;
    }   
    .....
  }
  </code></pre>
  
  <p>But than, how can I call it from the <code>fragment</code>?  </p>