Android examples for Phone:Phone Information
Obtain app version number
//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 { public static String getVersionName(Context context) throws NameNotFoundException { PackageManager packageManager = context.getPackageManager(); PackageInfo packInfo = packageManager.getPackageInfo( context.getPackageName(), 0); String version = packInfo.versionName; return version; }//from w w w . j a va2s. c om }