if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){ //do something }
import com.yourpackage.BuildConfig; ... int versionCode = BuildConfig.VERSION_CODE; String versionName = BuildConfig.VERSION_NAME;