title: Create Preference dynamically
body: <p>I am using this code to get a list of permission required by a specific application. I would like to create a Preference for each permission requested. How can I do this? The code is:</p>
  
  <pre><code>try {
          PackageInfo packageInfo = getPackageManager().getPackageInfo(myPackageName, PackageManager.GET_PERMISSIONS);
  
          String[] requestedPermissions = packageInfo.requestedPermissions;
          if ( requestedPermissions != null ) {
              for (int i = 0; i &lt; requestedPermissions.length; i++) {
                  permission.setSummary(requestedPermissions[i] + "\n");
              }
  
          }
      }
      catch ( PackageManager.NameNotFoundException e ) {
          e.printStackTrace();
      }
  </code></pre>