title: android global variable, getApplicationContext with ClassCastException
body: <p>Follow the advice from Stack Overflow question and answer, I create a class (Constant), and try to declare and use it as the global variable, but it failed to cast, can not find any good answer for this issue, I tried to define either "Constant" or ".Constant" in Manifest file, none of the definition works.</p>
  
  <p>Please help me out.</p>
  
  <pre><code>Constant con = ((Constant)getApplicationContext());  // failed to cast here
  con.setClientid(Integer.parseInt(clientid));
  
  import android.app.Application;
  
  public class Constant extends Application {
      private int gClientid;
      public int getClientid() { return gClientid; }   
      public void setClientid(int cid) { gClientid = cid; }   
  }
  </code></pre>
  
  <p>Manifest</p>
  
  <pre><code>&lt;application android:name=".Constant" android:icon="@drawable/icon"&gt;
  </code></pre>