Android APK Information Get getAppVersionName(Context context)

Here you can find the source of getAppVersionName(Context context)

Description

get App Version Name

Declaration

public static String getAppVersionName(Context context) 

Method Source Code

//package com.java2s;

import android.content.Context;

import android.content.pm.PackageInfo;

import android.content.pm.PackageManager.NameNotFoundException;

public class Main {
    public static String getAppVersionName(Context context) {
        PackageInfo appPackage = getAppPackage(context);
        return appPackage.versionName;
    }/* ww w. java 2 s. c  om*/

    public static PackageInfo getAppPackage(Context context) {
        PackageInfo appPackage = null;
        try {
            appPackage = context.getPackageManager().getPackageInfo(
                    context.getPackageName(), 0);
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
        return appPackage;
    }
}

Related

  1. restoreToUserApp(Context context)
  2. getApplicationName(Context context)
  3. getAppName(Context context)
  4. getAppPackage(Context context)
  5. getAppVersionCode(Context context)
  6. getApkIcon(Context context, String apkPath)