title: Cannot determine whether Google play store is installed or not on Android device
body: <p>This was a simple matter of checking the installed packages on the device... before I've upgraded my OS to 2.3.5, I could locate the Market/Play store, using this code:</p>
  
  <pre><code>private static final String GooglePlayStorePackageName = "com.google.market";
  
  void someMethod() {
      packageManager = getApplication().getPackageManager();
      List&lt;PackageInfo&gt; packages = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
      for (PackageInfo packageInfo : packages) {
          if (packageInfo.packageName.equals(GooglePlayStorePackageName)) {
              googlePlayStoreInstalled = true;
              break;
          }
      }
  }
  </code></pre>
  
  <p>For some reason after the update, I simply cannot find the to package name to indicate the application is installed, although it is on the device, and I can access the market.</p>
  
  <p>Has the package name changed? or perhaps I'm looking at this the wrong way?</p>
  
  <p>Thanks,</p>
  
  <p>Adam.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>That was a stupid way to check if a package is installed... a better way is:</p>
  
  <pre><code>protected final boolean isPackageInstalled(String packageName) {
      try {
          application.getPackageManager().getPackageInfo(packageName, 0);
      } catch (NameNotFoundException e) {
          return false;
      }
      return true;
  }
  </code></pre>