Java tutorial
//package com.java2s; 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 getVersionName(Context context) { PackageManager packageManager = getPackageManager(context); try { PackageInfo packageInfo = packageManager.getPackageInfo(getPacketName(context), 0); return packageInfo.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } return ""; } private static PackageManager getPackageManager(Context context) { return context.getPackageManager(); } public static String getPacketName(Context context) { return context.getPackageName(); } }