Activity having static reference
<p>I'm working on an exiting Android code written by someone else and it has several memory issues. One issue which i'm not able to understand is this. In the main Activity class it has a static method called getReference(). 
This method basically returns reference to a variable called <strong>mThis</strong>. Now, in <strong>onCreate</strong> method </p>

<pre><code>class MyActivity extends Activity
 {
     private static MyActivity mThis;    
     public MyActivity getReference(){
           return mThis;
    }
     public onCreate(Bundle savedInstanceState){
       mThis = this;
     }

    ...
}
</code></pre>

<p>Now in Content provider or class extending from Dialog class, it uses this static method to get reference to context. </p>

<p>I'm pretty sure this is not correct and is one of reason for memory leak. But is there a way to get the current context without actually passing the context object in every class. There is an application context but  i don't think it has any method to get the current context.</p>

<p>I can remove this method and then pass reference to context object to these classes. But is there any other way to fix this. </p>
