How to retrieve preferences in android
===

I am making an app that counts down from a time (e.g. 1 min) and then sends a text message to somebody. I am using preferences so that the user can set the time, phone number and message, but I don't know how to make it so that the timer,number and message variables are the ones set in the preferences and not the default ones. Here is the code I have so far.


    package com.countdowntimer;
       	 
    import android.app.Activity;
    import android.content.SharedPreferences;
    import android.os.Bundle;
    import android.os.CountDownTimer;
    import android.preference.PreferenceManager;
    import android.telephony.SmsManager;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.TextView;
       	 
        	public class CountdownTimer extends Activity implements OnClickListener
        	    {
        	        private MalibuCountDownTimer countDownTimer;
        	        private long timeElapsed;
        	        private boolean timerHasStarted = false;
        	        private Button startB;
        	        private TextView text;
        	        private TextView timeElapsedView;
       	 
        	        private final long startTime =     30000 ; //I want this to be the value from the preferences
        	        private final long interval =    1000 ;
        	        
        	        /** Called when the activity is first created. */
        	        @Override
        	        public void onCreate(Bundle savedInstanceState)
        	            {
        	                super.onCreate(savedInstanceState);
        	                setContentView(R.layout.activity_countdown_timer);
        	                
        	    	        
       	                    startB = (Button) this.findViewById(R.id.button);
        	                startB.setOnClickListener(this);
        	 
        	                text = (TextView) this.findViewById(R.id.timer);
        	                timeElapsedView = (TextView) this.findViewById(R.id.timeElapsed);
        	                countDownTimer = new MalibuCountDownTimer(startTime, interval);
        	                text.setText(text.getText() + String.valueOf(startTime/1000));
        	            }
        	 
        	        public void onClick(View v)
        	            {
        	                if (!timerHasStarted)
        	                    {
        	                        countDownTimer.start();
        	                        timerHasStarted = true;
        	                        startB.setText("Start Timer");
        	                    }
        	                else
        	                    {
        	                        countDownTimer.cancel();
        	                        timerHasStarted = false;
        	                        startB.setText("Stop Timer");
        	                    }
        	            }
        	 
        	        // CountDownTimer class
        	        public class MalibuCountDownTimer extends CountDownTimer
        	            {
       	 
        	                public MalibuCountDownTimer(long startTime, long interval)
        	                    {
        	                        super(startTime, interval);
        	                    }
        	 
        	                @Override
        	                public void onFinish()
        	                    {
        	                        text.setText("Time's up!");
       	                        timeElapsedView.setText("Time Elapsed: " + String.valueOf(startTime/1000));
       	                        sendSMS("07772417392", "The timer has finished!"); //These should also be the values from the preferences
        	                    }
        	 
        	                @Override
        	                public void onTick(long millisUntilFinished)
        	                    {
        	                        text.setText("Time remaining:" + millisUntilFinished/1000);
        	                        timeElapsed = startTime - millisUntilFinished;
        	                        timeElapsedView.setText("Time Elapsed: " + String.valueOf(timeElapsed/1000));
        	                    }
       	            }
        	        
        	        private void sendSMS(String phoneNumber, String Message) {
        	        	
        	        	SmsManager sms = SmsManager.getDefault();
        	        	sms.sendTextMessage(phoneNumber, null, Message, null, null);
        	        }
    	    }

I have looked at using SharedPreferences and PreferenceManager etc. but all the examples I look at don't really help me.