I just tried and found that you need to modify a file:
its default content is
1which means 'enable charging' you need to set it to
0to 'disable charging'
$ su $ echo 0 > /sys/class/power_supply/usb/device/charge
I tested on Nexus 4 and it's working successfully.
user3395818 has posted this answer. I have Nokia 3 and it comes with Android 7 Nougat. I am new to Android. How to perform the above task?
Please explain in detail with steps.