Android examples for Android OS:OS Version
get Current Version Name
//package com.java2s; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; public class Main { public static String getCurrentVersionName(Context context) { String currentVersionName = ""; try {//from w ww . j a v a2 s . co m PackageManager pm = context.getPackageManager(); PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0); currentVersionName = pi.versionName; if (currentVersionName == null || currentVersionName.length() <= 0) { currentVersionName = "1.0.0"; } } catch (Exception e) { currentVersionName = "1.0.0"; } return currentVersionName; } }