Here you can find the source of isPackageInstalled(final String packageName, final PackageManager pm)
public static boolean isPackageInstalled(final String packageName, final PackageManager pm)
//package com.java2s; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { public static boolean isPackageInstalled(final String packageName, final PackageManager pm) { String mVersion;//from w w w . java 2s . c om try { mVersion = pm.getPackageInfo(packageName, 0).versionName; if (mVersion.equals(null)) { return false; } } catch (NameNotFoundException e) { return false; } return true; } }