Using SharedPreferences across multiple classes?
I have a SharedPreferences that currently works in one class but doesn't work in a second class. I think I might be calling it wrong, because the error I get says:

    The method getSharedPreferences(String, int) is undefined for the type CheckPreferences

The code that works correctly with the SharedPrefernces is this:

    public void loadApp()
	{
	    setContentView(shc_BalloonSat.namespace.R.layout.main);
	    alert = new AlertDialog.Builder(this).create();
	    //String returned = "";
	    lastpacketsPHP = "";
	    pref = getSharedPreferences("shared_prefs", 1);
	    prefEditor = pref.edit();
	    //prefEditor.putString(lastpacketsPHP, "/* Insert PHP file location here */");
	    //prefEditor.commit();
	       
	    // These next two lines are used to test the PHP files on the SHC server by determining if PHP is set up correctly.
	    prefEditor.putString(lastpacketsPHP, "/* Insert PHP file location here */");
	    prefEditor.commit();   
	       
	    if (!isNetworkConnected(this))
	    {
		showAlert();
	    }
	    
	    else
	    {
		api = new httpAPI(this);
	        map = new mapAPI(this);
	        dialog = new runDialog(this, api, new runDialog.OnDataLoadedListener()
	        {
	            
        	    public void dataLoaded(String textViewString)
        	    {
        		infoTV = (TextView)findViewById(shc_BalloonSat.namespace.R.id.info);
        	        infoTV.setText(textViewString);
        	        assignInfoToInfoTextView();
        	        assignInfoToHistoryTextView();
        	    }
	        });
	        
	        dialog.execute();
	    }
	    
	    CheckPreferences cp = new CheckPreferences(this, new CheckPreferences.CheckPreferencesListener()
	    {
	        
	        public void onSettingsSaved()
	        {
	            // This function let's the activity know that the user has saved their preferences and
	            // that the rest of the app should be now be shown.
	            check.saveSettings();	            
	        }
	        
	        public void onCancel()
	        {
	            Toast.makeText(getApplicationContext(), "Settings dialog cancelled", Toast.LENGTH_LONG).show();
	        }
	    });
	    
	    cp.show();
	}

In my other class, I don't know if I'm just calling it incorrectly or if I'm looking at it completely incorrectly. The class is shown below:

    package shc_BalloonSat.namespace;
    import android.app.Dialog;
    import android.content.Context;
    import android.content.SharedPreferences;
    import android.content.SharedPreferences.Editor;
    import android.view.View;
    import android.widget.CheckBox;

    public class CheckPreferences extends Dialog
    {
    Context shc;
    private CheckBox altitudeCheckBox = (CheckBox) findViewById(R.id.altitudeCheckbox);
    private CheckBox latitudeCheckbox = (CheckBox) findViewById(R.id.latitudeCheckbox);
    private CheckBox longitudeCheckbox = (CheckBox) findViewById(R.id.longitudeCheckbox);
    private CheckBox velocityCheckbox = (CheckBox) findViewById(R.id.velocityCheckbox);
    private CheckPreferencesListener listener;
    SharedPreferences pref;
    Editor prefEditor;
    String userAltitudePreference;
    String userLatitudePreference;
    String userLongitudePreference;
    String userVelocityPreference;
    String userAltitudeChoice;
    String userLatitudeChoice;
    String userLongitudeChoice;
    String userVelocityChoice;
    
    public interface CheckPreferencesListener 
    {
	public void onSettingsSaved();
	public void onCancel();
    }
    
    public CheckPreferences(Context context, CheckPreferencesListener l)
    {
	super(context);
	this.setContentView(R.layout.custompreferences);
	this.setCancelable(false);
	this.setCanceledOnTouchOutside(false);
	this.setTitle("Data View Settings");
	pref = getSharedPreferences("shared_prefs", 1);
	prefEditor = pref.edit();
	initOnClick();
    }

    private void initOnClick()
    {
	View.OnClickListener click = new View.OnClickListener()
	{
	    public void onClick(View v)
	    {
		switch (v.getId())
		{
        		case R.id.saveBtn:
        		{
        		    saveSettings();
        		    listener.onSettingsSaved();
        		    dismiss();
        		    break;
        		}
        		
        		case R.id.cancelBtn:
        		{
        		    listener.onCancel();
        		    dismiss();
        		    break;
        		}
		}
	    }
	};
	
	    // Save Button
	    this.findViewById(R.id.saveBtn).setOnClickListener(click);
	    
	    // Cancel Button
	    this.findViewById(R.id.cancelBtn).setOnClickListener(click);
    }
	
    public void saveSettings()
    {
	// This function is called when the user chooses the save their preferences
	
	if (altitudeCheckBox.isChecked())
	{
	    userAltitudeChoice = "true";
	    prefEditor.putString(userAltitudePreference, userAltitudeChoice);
	    prefEditor.commit();   
	}
	
	else if (latitudeCheckbox.isChecked())
	{
	    userLatitudeChoice = "true";
	    prefEditor.putString(userLatitudePreference, userLatitudeChoice);
	    prefEditor.commit();  
	}
	
	else if (longitudeCheckbox.isChecked())
	{
	    userLongitudeChoice = "true";
	    prefEditor.putString(userLongitudePreference, userLongitudeChoice);
	    prefEditor.commit();  
	}
	
	else if (velocityCheckbox.isChecked())
	{
	    userVelocityChoice = "true";
	    prefEditor.putString(userVelocityPreference, userVelocityChoice);
	    prefEditor.commit();  
	}
	
	else
	{
	    
	}
	
    }
    }

The error I mentioned above occurs on this line:

    pref = getSharedPreferences("shared_prefs", 1);

Any help will be greatly appreciated. I'd love to know what I'm doing wrong.
Using SharedPreferences across multiple classes?
===

I have a SharedPreferences that currently works in one class but doesn't work in a second class. I think I might be calling it wrong, because the error I get says:

    The method getSharedPreferences(String, int) is undefined for the type CheckPreferences

The code that works correctly with the SharedPrefernces is this:

    public void loadApp()
	{
	    setContentView(shc_BalloonSat.namespace.R.layout.main);
	    alert = new AlertDialog.Builder(this).create();
	    //String returned = "";
	    lastpacketsPHP = "";
	    pref = getSharedPreferences("shared_prefs", 1);
	    prefEditor = pref.edit();
	    //prefEditor.putString(lastpacketsPHP, "/* Insert PHP file location here */");
	    //prefEditor.commit();
	       
	    // These next two lines are used to test the PHP files on the SHC server by determining if PHP is set up correctly.
	    prefEditor.putString(lastpacketsPHP, "/* Insert PHP file location here */");
	    prefEditor.commit();   
	       
	    if (!isNetworkConnected(this))
	    {
		showAlert();
	    }
	    
	    else
	    {
		api = new httpAPI(this);
	        map = new mapAPI(this);
	        dialog = new runDialog(this, api, new runDialog.OnDataLoadedListener()
	        {
	            
        	    public void dataLoaded(String textViewString)
        	    {
        		infoTV = (TextView)findViewById(shc_BalloonSat.namespace.R.id.info);
        	        infoTV.setText(textViewString);
        	        assignInfoToInfoTextView();
        	        assignInfoToHistoryTextView();
        	    }
	        });
	        
	        dialog.execute();
	    }
	    
	    CheckPreferences cp = new CheckPreferences(this, new CheckPreferences.CheckPreferencesListener()
	    {
	        
	        public void onSettingsSaved()
	        {
	            // This function let's the activity know that the user has saved their preferences and
	            // that the rest of the app should be now be shown.
	            check.saveSettings();	            
	        }
	        
	        public void onCancel()
	        {
	            Toast.makeText(getApplicationContext(), "Settings dialog cancelled", Toast.LENGTH_LONG).show();
	        }
	    });
	    
	    cp.show();
	}

In my other class, I don't know if I'm just calling it incorrectly or if I'm looking at it completely incorrectly. The class is shown below:

    package shc_BalloonSat.namespace;
    import android.app.Dialog;
    import android.content.Context;
    import android.content.SharedPreferences;
    import android.content.SharedPreferences.Editor;
    import android.view.View;
    import android.widget.CheckBox;

    public class CheckPreferences extends Dialog
    {
    Context shc;
    private CheckBox altitudeCheckBox = (CheckBox) findViewById(R.id.altitudeCheckbox);
    private CheckBox latitudeCheckbox = (CheckBox) findViewById(R.id.latitudeCheckbox);
    private CheckBox longitudeCheckbox = (CheckBox) findViewById(R.id.longitudeCheckbox);
    private CheckBox velocityCheckbox = (CheckBox) findViewById(R.id.velocityCheckbox);
    private CheckPreferencesListener listener;
    SharedPreferences pref;
    Editor prefEditor;
    String userAltitudePreference;
    String userLatitudePreference;
    String userLongitudePreference;
    String userVelocityPreference;
    String userAltitudeChoice;
    String userLatitudeChoice;
    String userLongitudeChoice;
    String userVelocityChoice;
    
    public interface CheckPreferencesListener 
    {
	public void onSettingsSaved();
	public void onCancel();
    }
    
    public CheckPreferences(Context context, CheckPreferencesListener l)
    {
	super(context);
	this.setContentView(R.layout.custompreferences);
	this.setCancelable(false);
	this.setCanceledOnTouchOutside(false);
	this.setTitle("Data View Settings");
	pref = getSharedPreferences("shared_prefs", 1);
	prefEditor = pref.edit();
	initOnClick();
    }

    private void initOnClick()
    {
	View.OnClickListener click = new View.OnClickListener()
	{
	    public void onClick(View v)
	    {
		switch (v.getId())
		{
        		case R.id.saveBtn:
        		{
        		    saveSettings();
        		    listener.onSettingsSaved();
        		    dismiss();
        		    break;
        		}
        		
        		case R.id.cancelBtn:
        		{
        		    listener.onCancel();
        		    dismiss();
        		    break;
        		}
		}
	    }
	};
	
	    // Save Button
	    this.findViewById(R.id.saveBtn).setOnClickListener(click);
	    
	    // Cancel Button
	    this.findViewById(R.id.cancelBtn).setOnClickListener(click);
    }
	
    public void saveSettings()
    {
	// This function is called when the user chooses the save their preferences
	
	if (altitudeCheckBox.isChecked())
	{
	    userAltitudeChoice = "true";
	    prefEditor.putString(userAltitudePreference, userAltitudeChoice);
	    prefEditor.commit();   
	}
	
	else if (latitudeCheckbox.isChecked())
	{
	    userLatitudeChoice = "true";
	    prefEditor.putString(userLatitudePreference, userLatitudeChoice);
	    prefEditor.commit();  
	}
	
	else if (longitudeCheckbox.isChecked())
	{
	    userLongitudeChoice = "true";
	    prefEditor.putString(userLongitudePreference, userLongitudeChoice);
	    prefEditor.commit();  
	}
	
	else if (velocityCheckbox.isChecked())
	{
	    userVelocityChoice = "true";
	    prefEditor.putString(userVelocityPreference, userVelocityChoice);
	    prefEditor.commit();  
	}
	
	else
	{
	    
	}
	
    }
    }

The error I mentioned above occurs on this line:

    pref = getSharedPreferences("shared_prefs", 1);

Any help will be greatly appreciated. I'd love to know what I'm doing wrong.