There are many question on that. Check Get Android API level of phone currently running my application and Programmatically obtain the Android API level of a device? . In these answers, you might see something like:
Integer.valueOf(android.os.Build.VERSION.SDK);
But .SDK
has been depreciated. Use SDK_INT
instead
//Check the condition as
if (android.os.Build.VERSION.SDK_INT>=11){}
See Build.VERSION.html#SDK_INT for more.
Update:
As kcoppock has nicely suggested, you may want to use something like:
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
//Do something
}