Bluetooth and Sensor Sketches

Help me understand some programming when using shields. I have a Bluetooth shield and I can connect with it after uploading a sketch that configures the shield but of course when I load another sketch such as a typical nonbluetooth sensor sketch it overwrites the Bluetooth settings. How do you incorporate the Bluetooth settings and use a known sketch at the same time or how do you add Bluetooth to an existing sketch? I want to read analog output from a sensor from the arduino to my phone.

I have a Bluetooth shield and I can connect with it after uploading a sketch that configures the shield but of course when I load another sketch such as a typical nonbluetooth sensor sketch it overwrites the Bluetooth settings.

No, it doesn't. It simply fails to set them. Big difference.

How do you incorporate the Bluetooth settings and use a known sketch at the same time or how do you add Bluetooth to an existing sketch?

Cut and paste.

I want to read analog output from a sensor from the arduino to my phone.

This hardly makes sense. Reading data from a sensor does. Reading to the phone does not.

All the code you posted looks fine to me.