Here you can find the source of getAPKVersion(Context context)
public static String getAPKVersion(Context context)
//package com.java2s; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { public static String getAPKVersion(Context context) { String APKVersion = ""; PackageManager pm = context.getPackageManager(); String packageName = context.getPackageName(); PackageInfo info = null;/* w ww. j a v a 2 s .c om*/ try { info = pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); } catch (NameNotFoundException e) { e.printStackTrace(); } if (info != null) { APKVersion = info.versionName + ""; } return APKVersion; } }