You can use the system info service. To get the OS version
Services.sysinfo.getProperty("version");
Consult the sources for the properties supported. Also pay attention to their platform-specific meaning (e.g. on Android there is version and kernel_version)