Here you can find the source of getAppVersion(Context context)
public static String getAppVersion(Context context)
//package com.java2s; import android.content.Context; public class Main { public static String getAppVersion(Context context) { try {/* w w w .j a va 2 s . co m*/ return context.getPackageManager().getPackageInfo( context.getPackageName(), 0).versionName; } catch (Exception e) { throw new RuntimeException(e); } } }