Here you can find the source of GetVersionCode(final Context con)
public static int GetVersionCode(final Context con)
//package com.java2s; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; public class Main { public static int GetVersionCode(final Context con) { int version = 1; PackageManager packageManager = con.getPackageManager(); try {//from ww w .java 2 s . c o m PackageInfo packageInfo = packageManager.getPackageInfo( con.getPackageName(), 0); version = packageInfo.versionCode; } catch (Exception e) { e.printStackTrace(); } return version; } }