SDK_INT is not available in very early versions. Therefore, if your manifest has, for example:
android:minSdkVersion="1"
you can use something like this:
@TargetApi(Build.VERSION_CODES.DONUT) static boolean getPreHoneyComb() { try { Build.VERSION.class.getField("SDK_INT"); } catch (NoSuchFieldException e) { return true; } return Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB; }
source share