Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { /** * Get give package version name. * * @param context Object of {@link Context}. * @param pkg Package name. * @return {@link String} of version name. */ public final static String getAppVersionName(Context context, String pkg) { PackageManager pm = context.getPackageManager(); try { PackageInfo info = pm.getPackageInfo(pkg, 0); return info.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); return null; } } }