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