Java tutorial
//package com.java2s; //License from project: Apache License import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageInfo; public class Main { /** * Fetch the versionName from the AndroicManifest.xml * * @param context * @return the versionName */ public static String getVersionName(Context context) { try { ComponentName comp = new ComponentName(context, context.getClass()); PackageInfo pinfo = context.getPackageManager().getPackageInfo(comp.getPackageName(), 0); return pinfo.versionName; } catch (android.content.pm.PackageManager.NameNotFoundException e) { return null; } } }