Android PackageInfo get package version name
import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; public class Main { public static String getVersionName(Context context) { try {/*from w w w. j a v a 2s .co m*/ String pkName = context.getPackageName(); PackageManager pkg = context.getPackageManager(); PackageInfo info = pkg.getPackageInfo(pkName, 0); String versionName = info.versionName; return versionName; } catch (Exception e) { } return ""; } }