Java: Need some way to shorten this code
<p>I have this piece of code that I would like to shorten...</p>

<pre><code>    PackageManager p = context.getPackageManager();
    final List&lt;PackageInfo&gt; appinstall = p.getInstalledPackages(PackageManager.GET_PERMISSIONS);
    PackageManager pro = context.getPackageManager();
    final List&lt;PackageInfo&gt; apllprovides = pro.getInstalledPackages(PackageManager.GET_PROVIDERS);
</code></pre>

<p>I am seriously irritated to do this again and again to add new flag permissions, and I need to do it a couple of times, is there a shorter method in which I could put all the flags on the same definition...???</p>

<p>Let me put it this way, can I do this...??? (of course this gives an error, but something similar..)</p>

<pre><code>    PackageManager p = context.getPackageManager();
    final List&lt;PackageInfo&gt; appinstall = p.getInstalledPackages(PackageManager.GET_PERMISSIONS).addFlag(PackageManager.GET_PROVIDERS);
</code></pre>
