#ifdef
is for compile-time processing, and even if that were generally an accepted practice in Java (it's not, but 3rd party tools do exist to support the concept), it would not likely help you, since you need to make a runtime decision about the environment you're running in (unless you want to generate multiple packages?).
As the link fabricemarcelin provided (http://stackoverflow.com/questions/3506792/android-api-version-programmatically) states, you can determine the version of your runtime system easily enough. You'll need to write your application to the API you know will exist at runtime (the 2.2 system, if that's your lower limit), and you'll need to make a runtime decision about calling the 4.0 functions. For 4.0 functionality, you'll likely need to find your APIs using reflection.
I've made use of reflection to access things otherwise only available on newer Android systems and it's worked well. One tip though is to arrange to perform the reflection / API location early in your application if reasonable, and if not, at least arrange to only do it once per call.