Is there anything wrong with using a public static Context? ( Regarding getResources() )
<p>Recently I ran into a problem when trying to load an bitmap outside of my main class.  I found that within my main class I could pass this as a Context to any given function allowing me to call getResources() from within that function.  There are a couple of things about this which don't make sense to me.</p>

<p>The keyword "this" simply refers to the current object the function is running in, right? If so, how can I pass my main class as a Context by using "this"?  It doesn't even have a Context in it.  I am using "extends Activity", but Activity doesn't seem to contain any function called getResources() in it either.</p>

<p>I found a workaround which allows me to do what I want a bit easier which is to declare a public static Context appContext; within my main class.  Then, within onCreate() I set appContext = this;  Then, from elsewhere I can call MainActivity.appContext.getResources() whenever I need it.  So, I really have a few questions here.</p>

<ol>
<li><p>Why are MainActivity(my main class) and appContext not essentially the same thing when appContext is set to "this" from inside MainActivity (There is no such thing as MainActivity.getResources())</p></li>
<li><p>Is this unsafe to do?  Could this cause any potential problems in my program?</p></li>
<li><p>Is there a way to load images without having to use getResources()?</p></li>
<li><p>What is the proper way to show my code in this website? The standard I am used to ([code][/code] tags) don't seem to work properly in the preview, so I am assuming it is handled differently here. The formatting help page says to simply use four spaces, but that doesn't seem to show any difference in the preview section either.</p></li>
</ol>

<p>EDIT:
I just read in another thread somebody said</p>

<blockquote>
  <p>now everything depends on your main activity's onCreate method having been called.</p>
</blockquote>

<p>That got me thinking.  Under what circumstances would onCreate not be called?  It seems like if it wasn't called the program would stop working properly in many ways not related to having a static variable initialized inside it(ie. setContentView would not be called).</p>

<p>So assuming that there is nothing wrong with doing it this way, the only drawback I can find, is that "MainActivity.appContext.getResources()" is a lot to type to call a function.  Is there any way to create a sort of alias for this? I suppose I could create a function which simply calls that, but that just seems silly.</p>
