Code example for Spinner

Methods: getItemAtPosition, getSelectedItemPosition

        // Apply the adapter to the spinner 
    public void readPref(View v) {
    	String key = sp.getItemAtPosition(sp.getSelectedItemPosition()).toString();
    	SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    	String pref = null;
    	if (key.startsWith("pref_text")) pref = sharedPref.getString(key, "");
    	else if (key.startsWith("pref_chkbx")) pref = Boolean.toString(sharedPref.getBoolean(key, false));
    	else if (key.startsWith("pref_list")) pref = sharedPref.getString(key, "");
    	Toast.makeText(this, "Key: "+key+" | Value: "+pref, Toast.LENGTH_LONG).show();
Connect your IDE to all the code out there  Get Codota for Java