Here you can find the source of getVersionCode(Context mContext)
public static int getVersionCode(Context mContext)
//package com.java2s; import android.content.Context; import android.content.pm.PackageManager; public class Main { public static int getVersionCode(Context mContext) { int versionCode = 0; try {// w w w .j av a 2s . c o m versionCode = mContext.getPackageManager().getPackageInfo( mContext.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return versionCode; } }