I know this has been asked before(and I have read lots of posts here about them) but I can’t figure out what I’m doing wrong. I want to set some things up as global variables to use throughout my app. So I created a new folder (which I think created a new app?) with a class in it :

Which is all good. In the Global.java I have the following:
package com.directenquiries.assessment.tool.Globals;
import android.app.Application;
import android.os.Environment;
public class Global extends Application {
public String foo;
public String SDcard = Environment.getExternalStorageDirectory().getAbsolutePath();
}
My Manifest file now looks like: (which I think might be the culprit?)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.directenquiries.assessment.tool"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".LoginPageActivity"
android:label="@string/title_activity_login_page" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<application
android:name="Global"
android:label="@string/app_name" >
</application>
</manifest>
And I’m trying to call the variable back in my LoginPageActivity like:
String SDLoc = ((Global) this.getApplication()).foo;
TextView obs = (TextView) findViewById(R.id.textView1);
obs.setText(SDLoc);
But my app falls over with:
09-11 14:14:19.354: W/dalvikvm(5339): threadid=1: thread exiting with uncaught exception (group=0x40c4f1f8)
09-11 14:14:19.359: E/AndroidRuntime(5339): FATAL EXCEPTION: main
09-11 14:14:19.359: E/AndroidRuntime(5339): java.lang.ClassCastException: android.app.Application cannot be cast to com.directenquiries.assessment.tool.Globals.Global
Any help will be appreciated
Modify
public String footopublic final static String fooand than you can refere to asGlobal.foo.You don’t need to put Global class in another package.