Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { private static PackageManager pm = null; /** * get version name of this app * @param context context * @return version name */ public static String getVersionName(Context context) { if (pm == null) { pm = context.getPackageManager(); } try { return pm.getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } return null; } }