Skip to content

Instantly share code, notes, and snippets.

@SeanZoR
SeanZoR / getVersionCode
Created February 22, 2014 11:02
Android - Get application version code
public static int getVersionCode(Context ctx) {
int versionCode = 0;
try {
PackageInfo pInfo = ctx.getPackageManager().getPackageInfo(
ctx.getPackageName(), 0);
versionCode = pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}