Prevent USB Access on Android Devices with Root Access

In case your device is rooted, you could attempt this method that worked for me. You need to locate the file that indicates authorized devices for your port and clear it. However, note that the path may vary depending on your system, so you might need to search for it. I have a platform based on Freescale HW & BSP. This process can be performed from a shell session or through a script or shell commands executed within an application. To re-enable the settings, simply follow the same steps. By changing the settings in this way, I was able to both enable and disable a USB keyboard and a mass storage device such as a thumb drive.


In the drivers, define the USB by specifying its name after using the echo command as shown in the code below.

String command = "echo 'usb1' > /sys/bus/usb/drivers/usb/unbind";

Frequently Asked Questions