As described in the Android documentation, the SDK level (integer) of the phone is running are available in:
Android.os.Build.VERSION.SDK_INT;
The enum corresponding to this Int. Android.os.Build.VERSION_CODES class.
Code Example:
int currentapiversion=android.os.build.version.sdk_int;
if (currentapiversion >= Android.os.Build.VERSION_CODES. FROYO) {
Do something
}else{
Do something
}
Note:
This sdk_int is available since donut (Android 1.6/api4)
So make sure your application isn't retro-compatible with cupcake (Android 1.5/api3) when to use it or your application Would crash (to programmer Bruce for the precision).
====================================================================================
Build.version_codes
1 (0x00000001) Android 1.0 BASE
2 (0x00000002) Android 1.1 base_1_1
3 (0x00000003) Android 1.5 cupcake
4 (0x00000004) Android 1.6 Donut
5 (0x00000005) Android 2.0 Eclair
6 (0x00000006) Android 2.0.1 eclair_0_1
7 (0x00000007) Android 2.1 eclair_mr1
8 (0x00000008) Android 2.2 FROYO
9 (0x00000009) Android 2.3 Gingerbread
Ten (0x0000000a) Android 2.3.3 GINGERBREAD_MR1
One (0x0000000b) Android 3.0 Honeycomb
(0x0000000c) Android 3.1 honeycomb_mr1
0x0000000d Android 3.2 HONEYCOMB_MR2
Build.version_codes:http://developer.android.com/reference/android/os/build.version_codes.html