Java tutorial
//package com.java2s; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; public class Main { public static String getVersionName(Context context) { String versionName = ""; try { PackageInfo info = getPackageInfo(context); versionName = info.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } return versionName; } private static PackageInfo getPackageInfo(Context context) throws NameNotFoundException { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0); } }