Global Variable class not working
<p>I am trying to setup and global variable, but I my app fails after adding the following line to my AndroidManifest.xml</p>

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

<p>I am using the following code as well:</p>

<p>Class:
    package com.mynamecompany.datahelp;</p>

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

class MyApp extends Application {

      private String myState;

      public String getState(){
        return myState;
      }
      public void setState(String s){
        myState = s;
      }
    }
</code></pre>

<p>Usage:</p>

<pre><code>MyApp appState = ((MyApp)getApplicationContext());
String state = appState.getState();
Toast.makeText(getApplicationContext(), "My Value-" + state, Toast.LENGTH_SHORT).show();
appState.setState("Test");
Toast.makeText(getApplicationContext(), "My Value-" + appState.getState(), Toast.LENGTH_SHORT).show();
</code></pre>

<p>The program starts and errors immediately on the Splash screen before the usage code can be called further in the program, on a different Activity.</p>

<p>Any ideas?               </p>
