title: Using ApplicationInfo.FLAG_SYSTEM to filter out System Apps
body: <p>I am using following code to differentiate between User Installed App and System App:</p>
  
  <pre><code>final PackageManager pm = getPackageManager();
  List&lt;ApplicationInfo&gt; packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
  for (ApplicationInfo packageInfo : packages)
  {
      if ((packageInfo.flags &amp; ApplicationInfo.FLAG_SYSTEM) != 0)
          Log.d(TAG, "Installed package (System) :" + packageInfo.packageName);
      else
          Log.d(TAG, "Installed package (User) :" + packageInfo.packageName);
  }
  </code></pre>
  
  <p>How ever this gives some apps as User Installed Apps which are actually not. Following is the LogCat in my emulator:</p>
  
  <pre><code>Installed package (User) :com.android.smoketest
  Installed package (User) :com.android.widgetpreview
  Installed package (User) :com.example.android.livecubes
  Installed package (User) :com.example.android.apis
  Installed package (User) :com.android.gesture.builder
  Installed package (User) :com.example.android.softkeyboard
  Installed package (User) :com.android.smoketest.tests
  Installed package (User) :faheem.start
  </code></pre>
  
  <p>Ideally, only last application should be output in User Installed Apps.</p>