title: How to get the list of all non system apps in android
body: <p>I am developing an application, in which i want to get the list of all non system apps. Here is my code part:</p>
  
  <pre><code>TextView tv = new TextView(this);
          this.setContentView(tv);
  
          ActivityManager actvityManager = (ActivityManager)
          this.getSystemService( ACTIVITY_SERVICE );
          PackageManager pm = this.getPackageManager();
          List&lt;PackageInfo&gt; list =pm.getInstalledPackages(0);
  
          for(int i=0;i&lt;list.size();i++)
          {
              System.out.println("list"+i+"   "+list.get(i));
          }
  
          for(PackageInfo pi : list) 
          {
              try
              {
                  ApplicationInfo ai=pm.getApplicationInfo(pi.packageName, 0);
  
                  if (ai.sourceDir.startsWith("/data/app/"))
                  {
                      tv.setText(ai.className);// non system apps
                  }
                  else 
                  {
                       System.out.println("system apps");// system apps
                  }
              }
              catch(Exception e)
              {
                  e.printStackTrace();
  
              }
          }
  </code></pre>
  
  <p>but it showing, all the app as system apps</p>