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