title: Get Only Installed Apps in the List ( Not the system apps )
body: <p>I was implementing code to show only the user-installed apps (like facebook) and some updated_system_apps (like Gmail,youtube etc.) using the below code. But It is showing some other apps too. So my question is what is the way to remove these types of apps.</p>
  
  <p>My ultimate aim is to show app list just like Google Play Store shows them.</p>
  
  <p>I have read these solutions:
  <a href="https://stackoverflow.com/questions/6165023/get-list-of-installed-android-applications">Get list of installed android applications</a></p>
  
  <p><a href="https://stacktips.com/tutorials/android/how-to-get-list-of-installed-apps-in-android" rel="noreferrer">https://stacktips.com/tutorials/android/how-to-get-list-of-installed-apps-in-android</a></p>
  
  <p><a href="http://theopentutorials.com/tutorials/android/listview/how-to-get-list-of-installed-apps-in-android/" rel="noreferrer">http://theopentutorials.com/tutorials/android/listview/how-to-get-list-of-installed-apps-in-android/</a></p>
  
  <p><a href="https://www.android-examples.com/get-list-installed-apps-package-name-icons/" rel="noreferrer">https://www.android-examples.com/get-list-installed-apps-package-name-icons/</a></p>
  
  <p><a href="https://inducesmile.com/android/android-list-installed-apps-in-device-programmatically/" rel="noreferrer">https://inducesmile.com/android/android-list-installed-apps-in-device-programmatically/</a></p>
  
  <pre><code>packageManager = getPackageManager();
  
  List&lt;PackageInfo&gt; packageInfoList = packageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
  List&lt;PackageInfo&gt; installedPackageInfo = new ArrayList&lt;PackageInfo&gt;();
  
  for(PackageInfo pi: packageInfoList){
      if(!isSystemPackage(pi)){
            installedPackageInfo.add(pi);
      }
  }
  </code></pre>
  
  <pre><code>boolean isSystemPackage(PackageInfo pkgInfo){
          if((pkgInfo.applicationInfo.flags &amp; ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)!=0)
              return false;
          else if((pkgInfo.applicationInfo.flags &amp; ApplicationInfo.FLAG_SYSTEM)!=0)
              return true;
          else if((pkgInfo.applicationInfo.flags &amp; ApplicationInfo.FLAG_INSTALLED)!=0)
              return false;
          else
              return true;
  
      }
  </code></pre>
  
  <p>Update: I have added the image showing some non-relevant apps.</p>
  
  <p><a href="https://i.stack.imgur.com/rhVpim.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/rhVpim.jpg" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/Ht0hJm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Ht0hJm.jpg" alt="enter image description here"></a></p>