Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { public static String getAppVersion(Context context) { String versionName = null; try { PackageManager pManager = context.getPackageManager(); PackageInfo pInfo = pManager.getPackageInfo(context.getPackageName(), 0); versionName = pInfo.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } return versionName; } }