Skip to content

Instantly share code, notes, and snippets.

@darwind
Created August 7, 2014 13:19
Show Gist options
  • Select an option

  • Save darwind/b4ba332a0ecac9c434da to your computer and use it in GitHub Desktop.

Select an option

Save darwind/b4ba332a0ecac9c434da to your computer and use it in GitHub Desktop.
Gets the versioncode of the current app.
public int getVersionCode() {
int versionCode = 0;
try {
versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
// Huh? Really?
}
return versionCode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment