Android Context Get getVersion(Context context)

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

Description

get Version

Declaration

private static String getVersion(Context context) 

Method Source Code

//package com.java2s;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

public class Main {
    private static String getVersion(Context context) {
        String version = null;/*from  ww w  .ja va2 s  .  c  om*/
        try {
            PackageInfo pInfo = context.getPackageManager().getPackageInfo(
                    context.getPackageName(), PackageManager.GET_META_DATA);
            version = pInfo.versionName;
        } catch (NameNotFoundException e1) {

        }
        return version;
    }
}

Related

  1. getTCItalicFont(Context context)
  2. getTempFile(Context context)
  3. getTimestamp(Context context)
  4. getTypeface(Context context, String name)
  5. getUserAgentString(Context context)
  6. getVersionCode(Context mContext)
  7. getVoiceSearchIMId(Context context)