Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.*; import android.content.pm.*; public class Main { public static int getVersionCode(Context app) { PackageManager pm = app.getPackageManager(); PackageInfo pi; try { pi = pm.getPackageInfo(app.getPackageName(), 0); return pi.versionCode; } catch (Exception e) { e.printStackTrace(); return 1; } } }