I've looked through a lot of the posts and tried them, but nothing seems to work. I think it probably something I've missed. Here is what I'm trying to do and my problem: I'm trying to create a Global Variable, so that on my Main Activity, when a user select an item from the ListView, I want to assign that Item to the Variable and use it through out my application. 

Firs I created a Class and extends it to the Application like follow:

import android.app.Application;

public class GlobalVariables extends Application {

```
private String mStringValue;

public String getSomeVariable() {
    return mStringValue;
}

public void setSomeVariable(String someVariable) {
    this.mStringValue = someVariable;
}

```

}

Then in my Main Activity I put this this code to set the variable:

```
public class MainActivity extends Activity {    

@Override 
public void onCreate(Bundle savedInstanceState) {   
    super.onCreate(savedInstanceState);   
    setContentView(R.layout.activity_main);     

 ListView.setOnItemClickListener(new OnItemClickListener() {    

 @Override   
 public void onItemClick(AdapterView<?> listView, View view,       
int position, long id) {    

// Get the cursor, positioned to the corresponding row in the result set    
Cursor cursor = (Cursor) listView.getItemAtPosition(position);      
// Get the Customer Name from this row in the database.    
String countryCode = cursor.getString(cursor.getColumnIndexOrThrow("CustomerName"));    

Toast.makeText(getApplicationContext(), countryCode, Toast.LENGTH_SHORT).show();      

((GlobalVariables) this.getApplication()).setSomeVariable(countryCode);

   }   

});  

```

The problem is I'm getting the error "The method getApplication() is undefined for the type new AdapterView.OnItemClickListener(){}" at this line:

```
((GlobalVariables) this.getApplication()).setSomeVariable(countryCode);

```

I read one of the post suggested to do the follow code, but then I get another multiple errors:

* The method getApplication() is undefined for the type GlobalVariables
* No enclosing instance of the type GlobalVariables is accessible in scope

((GlobalVariables) GlobalVariables.this.getApplication()).setSomeVariable("foo");

Any help you could give me would be greatly appreciated. 

Thank you,

Tim