Java tutorial
//package com.java2s; import android.app.Activity; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { public static int getVersionCode(Activity context) { PackageManager packageManager = context.getPackageManager(); PackageInfo packInfo = null; try { packInfo = packageManager.getPackageInfo(context.getPackageName(), 0); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (packInfo != null) { return packInfo.versionCode; } return 0; } }