title: Is it safe to save the app context to a static variable in Android?
body: <p>I know that usage of static variables on Android is quite risky, especially if you reference them to activities. However, if I have a class that extends Application (let's call this class "App"), is it safe to reference to the instance of this class?</p>
  
  <p>If so, is it also safe for any other class to have any kind of reference to the application context? I mean, can there be a memory leak if I have a reference to the application context in any kind of class?</p>
  
  <p>The purpose is that no matter in which scope I am in, I can always get a reference to the application context. I think it's safe, since if the system closes the application, the static variable is also gone till the next time the application starts again, which will initialize the static variable again.</p>
  
  <p>Also, not that it matters much, but if I use multiple processes, will I get totally different references to App class on each process?</p>
  
  <p>As an example of code, here's what I'm thinking about:</p>
  
  <pre><code>public class App extends Application
  {
      private static Context _appContext;
  
      @Override
      public void onCreate()
      {
          super.onCreate();
          _appContext = this;
      }
  
      public static Context getAppContext()
      {
          return _appContext;
      }
  }
  </code></pre>