(Transferred from: http://www.cnblogs.com/qsl568/archive/2012/03/14/2395636.html)
Gets the version number of the current app:
Private throws Exception { // get an instance of Packagemanager Packagemanager Packagemanager = Getpackagemanager (); // Getpackagename () is the package name of your current class, and 0 means to get version information PackageInfo packinfo = Packagemanager.getpackageinfo (Getpackagename (), 0); = packinfo.versionname; = Packinfo.versioncode; return version; }
Gets the version number of the current system:
1 2 3
Or:
1 /* 2 * 3 * Build.version_codes4 1 (0x00000001) Android 1.0 BASE5 2 (0x00000002) Android 1.1 base_1_16 3 (0x00000003) Android 1.5 cupcake7 4 (0x00000004) Android 1.6 Donut8 5 (0x00000005) Android 2.0 Eclair9 6 (0x00000006) Android 2.0.1 eclair_0_1Ten 7 (0x00000007) Android 2.1 eclair_mr1 One 8 (0x00000008) Android 2.2 FROYO A 9 (0x00000009) Android 2.3 Gingerbread - Ten (0x0000000a) Android 2.3.3 GINGERBREAD_MR1 - One (0x0000000b) Android 3.0 Honeycomb the (0x0000000c) Android 3.1 honeycomb_mr1 - (0x0000000d) Android 3.2 honeycomb_mr2*/ - /*get the Android version number of the current system*/ - intCurrentapiversion=android.os.build.version.sdk_int;
Android Gets the current version number of the app & gets the version number of the current Android system