I just tried and found that you need to modify a file:
sys/class/power_supply/usb/device/charge
its default content is
1
which means 'enable charging' you need to set it to0
to '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.
/sys
can heavily vary between different devices, and even if there is such a file there, some devices might not allow you to modify it, or the modification would not come into effect.