Spinner is returning NullPointerException inside OnClick
<p>I have a spinner that is populated by values from a string array. I can get the value perfectly from the spinner through LogCat, but when I try get the value inside my inner class which holds an onClick method, LogCat doesn't show the value, or any message at all. I'm trying to add the value from the spinner to my helper, but it comes back with a NullPointerException. I'm not quite sure why, I've provided a LogCat screenshot and the code I'm using below. All help is greatly appreciated!</p>

<p><strong>Screenshot:</strong>
<img src="http://i.stack.imgur.com/CEefj.png" alt="enter image description here"></p>

<pre><code>package com.example.weatherapplication;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

public class AddCity extends Activity {
EditText name, country;
Button add;
String textSpin;
Spinner sp;

// ISOCodes - this took forever!
String[] ISOCODES = new String[] { "GB", "US" };

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.addcity);

    name = (EditText) findViewById(R.id.name);
    add = (Button) findViewById(R.id.add);
    sp = (Spinner) findViewById(R.id.countryList);

    // populate spinner with ISOCODES
    sp.setAdapter(new ArrayAdapter&lt;String&gt;(this,
             android.R.layout.simple_spinner_item, ISOCODES));

    textSpin = sp.getSelectedItem().toString();

    add.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (name.getText().toString().matches("") || country.getText().toString().matches("")) {
                Toast.makeText(AddCity.this , "Field can't be empty" , Toast.LENGTH_SHORT).show();
            } else {
                DataBaseHelper helper = new DataBaseHelper(AddCity.this);
                helper.openDataBase();
                Log.w("Spinner value two:", textSpin);
                helper.insert(name.getText().toString(), textSpin, R.drawable.red_bg);
                helper.close();
                finish();
            }
        }
    });
  }
}
</code></pre>
