user1067528
user1067528

Reputation:

Why can the code android.os.Build.VERSION.SDK_INT can run correctly?

if(android.os.Build.VERSION.SDK_INT >= 11) {
 adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, cur, cols, views,0); 
}else{ 
adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, cur, cols, views); } 

I think the code above will cause error because adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, cur, cols, views,0); can work only API.sdk >=11 , now my app is android:minSdkVersion="8", but the code is OK in the app, why? Normally the eclipse system will tell me android:minSdkVersion must be larger than 11 when compile. Thanks!

Upvotes: 0

Views: 425

Answers (1)

Kevin Coppock
Kevin Coppock

Reputation: 134714

Because you're compiling against a targetSdkVersion greater than or equal to 11. The code will only be run on a device >= 11 because of the safety check, so no, you should have no issues with this code.

Upvotes: 1

Related Questions