Here you can find the source of getAppVer(Context context)
public static String getAppVer(Context context)
import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.net.wifi.WifiManager; import android.os.Environment; import android.preference.PreferenceManager; import java.io.File; import java.io.FileInputStream; import java.io.ObjectInputStream; import java.text.SimpleDateFormat; import java.util.Map; import java.util.Map.Entry; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class Main{ public static String getAppVer(Context context) { try {//from w ww . ja v a 2 s . c om PackageInfo packageInfo = context.getPackageManager() .getPackageInfo(context.getPackageName(), 0); return packageInfo.versionName + "(" + packageInfo.versionCode + ")"; } catch (Throwable e) { Logger.w("getPackageInfo failed", e); return ""; } } }