title: How to get Size of installed application in android device?
body: <pre><code>public void getAppSize(ArrayList&lt;ApplicationInfo&gt; data) {
          for (int m = 0; m &lt; data.size(); m++) {
              packageManager = getPackageManager();
              Method getPackageSizeInfo;
  
              try {
                   getPackageSizeInfo =  packageManager.getClass().getMethod("getPackageSizeInfo", String.class, IPackagestatsObserver.class);
                  if (getPackageSizeInfo != null) {
                      try {
                          getPackageSizeInfo.invoke(packageManager, data.get(m).packageName, new cachePackState());
                      } catch (IllegalAccessException | InvocationTargetException e) {
                          e.printStackTrace();
                      }
                  }
              } catch (NoSuchMethodException e) {
                  e.printStackTrace();
              }
  
          }
      }
  </code></pre>