Java tutorial
//package com.java2s; import android.content.Context; public class Main { public static int getVersionCode(Context context) { int versionCode = 0; try { versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (Exception e) { } return versionCode; } }