How can I check the system version of Android?


Question

Does anyone know how can I check the system version (e.g. 1.0, 2.2, etc.) programatically?

1
462
10/29/2012 2:20:04 PM

Accepted Answer

Check android.os.Build.VERSION.

  • CODENAME: The current development codename, or the string "REL" if this is a release build.
  • INCREMENTAL: The internal value used by the underlying source control to represent this build.
  • RELEASE: The user-visible version string.
407
3/31/2013 3:59:00 PM

Example how to use it:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
     // only for gingerbread and newer versions
}

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon