Android gets the current software version number and version name. android version number
<Span style = "font-size: 18px;">/*** obtain the local software version */public static int getLocalVersion (Context ctx) {int localVersion = 0; try {PackageInfo packageInfo = ctx. getApplicationContext (). getPackageManager (). getPackageInfo (ctx. getPackageName (), 0); localVersion = packageInfo. versionCode; LogUtil. d ("TAG", "version of the software .. "+ LocalVersion);} catch (NameNotFoundException e) {e. printStackTrace ();} return localVersion;}/*** get the local software version name */public static String getLocalVersionName (Context ctx) {String localVersion = ""; try {PackageInfo packageInfo = ctx. getApplicationContext (). getPackageManager (). getPackageInfo (ctx. getPackageName (), 0); localVersion = packageInfo. versionName; LogUtil. d ("TAG", "version of the software .. "+ LocalVersion);} catch (NameNotFoundException e) {e. printStackTrace ();} return localVersion ;}</span>