Android examples for android.content.pm:App
get App Version Code
import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; public class Main { public static int getAppVersionCode(Context context) { PackageManager packageManager = context.getPackageManager(); PackageInfo packInfo = null;//from w ww . j ava2s.com try { packInfo = packageManager.getPackageInfo(context.getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } int code = packInfo.versionCode; return code; } }