Creating a global variable
<p>I'm trying to implement a basic login in my app. What I want to do is set a "Global" variable as true / false if user is logged in.</p>

<p>I've followed <a href="http://stackoverflow.com/questions/708012/android-how-to-declare-global-variables">this tutorial</a>.
So this is my code now:</p>

<pre><code>import android.app.Application;

public class GlobalParameters extends Application{
    private boolean loggedIn;

    public boolean isLoggedIn() {
    return loggedIn;
    }

    public void setLoggedIn(boolean loggedIn) {
    this.loggedIn = loggedIn;
    }
}
</code></pre>

<p>And this is on my <code>onCreate</code>:</p>

<pre><code>GlobalParameters gp = ((GlobalParameters)getApplicationContext());
gp.setLoggedIn(false);
</code></pre>

<p>But <code>GlobalParameters gp = ...</code> throws this exception:</p>

<blockquote>
  <p>ClassCastException</p>
</blockquote>

<p>I've added this too in my manifest:</p>

<pre><code>&lt;application android:name=".GlobalParameters" 
   android:icon="@drawable/ic_launcher" 
   android:label="@string/app_name"&gt;
&lt;/application&gt;
</code></pre>

<p>Any idea?</p>

<p>Thanks.</p>
