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