code: public static boolean isAppInstalled(final Context context, final String packageName){
          try {
              context.getPackageManager().getPackageInfo(packageName, 0);
              return true;
          } catch (Exception e) {
              return false;
          }
      }
docs: Check if app for the given package name is installed on this device.