Mega Code Archive

 
Categories / Android / Hardware
 

Get Version Code

import android.content.Context; import android.content.pm.PackageManager.NameNotFoundException; class Utils {   public static int getVersionCode(Context ctx) {     int vc = 0;     try {       vc = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionCode;     } catch (NameNotFoundException e) {       // TODO Auto-generated catch block       e.printStackTrace();     }     return vc;   } }