Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; public class Main { public static int getAppVerCode(Context ctx) { try { PackageInfo info = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), PackageManager.GET_CONFIGURATIONS); return info.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return 0; } } }