Android: get Application with a static method
<p>I'm using the pattern of extending <code>Application</code> class to save my global variables (<a href="http://stackoverflow.com/a/708317/1709805">http://stackoverflow.com/a/708317/1709805</a>). From my Android Components (<code>Activity</code>, <code>Fragment</code>, <code>Service</code>, ecc) i access them using (<code>(MyApp) getApplicaction()</code>), but in my project i have a lot of helper classes where i can't (obviously) use that method. To solve this problem i have decalred a static method which returns the Application. This is the code:</p>

<pre><code>public class MyApp extends Application{

  private static MyApp app;

  @Override
  public void onCreate(){
      super.onCreate();
      app = this;
  }

  public static MyApp getApp() {
      return app;
  }
}
</code></pre>

<p>is it a good pattern? Any suggestion to achieve my purpose in a better way? Thank you</p>
