Here you can find the source of getPackageVersionAsInt(Context c)
public static int getPackageVersionAsInt(Context c)
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.util.Log; public class Main { public static int getPackageVersionAsInt(Context c) { int packageVersion = 0; try {// ww w .j a v a 2s . com PackageInfo pInfo = c.getPackageManager().getPackageInfo( c.getPackageName(), 0); packageVersion = pInfo.versionCode; } catch (PackageManager.NameNotFoundException e) { Log.e("getPackageVersion", "Unable to read PackageName in RegisterApp"); e.printStackTrace(); } return packageVersion; } }