Can I grant permanent access to external storage to an app in Nougat? I'm using OnePlus 5 running stock 7.1.1.

I use the OTG function to transfer file between my phone and my flash drive very often, and my preferred file manager is Root Explorer. Every time I try to copy stuff to flash drive, I must first grant it access.

Can I permanently grant Root Explorer access to external storage? I don't mind messing around with system configuration files (like packages.xml).
Manually granting permission

For rooted devices, there is a way to inject a specific permission inside the /data/system/packages.xml file, which details any and all installed apps, alongside their signatures and permissions.

The permission mentioned above is &lt;item name="android.permission.WRITE_MEDIA_STORAGE" granted="true" flags="0" /&gt;, which is usually granted to system apps only. This line must be added under the &lt;perms&gt; node of the package name one wishes to grant permanent access to the external storage, be it an SD card or a drive attached via OTG.

For Android to acknowledge the new permission, a reboot is needed.

Revoking permission

To revoke the abovementioned permission, one just needs to remove the &lt;item name="android.permission.WRITE_MEDIA_STORAGE" granted="true" flags="0" /&gt; line they themselves added.

Automated alternatives

If one does not want to manually edit packages.xml but has Xposed, it is possible to achieve a similar result by using the XInternalSD module. Upon activating it, enter its settings and disable any checkbox but the one next to Full access to external SD card.

This, depending on the Android version in use, is able to grant read-write access to external media. It is tested and running up to Nougat 7.1.2. This method is not granular, hence any app will be able to access any external media.

I am not affiliated to either XInternalSD, or to its developer.