user91579631 user91579631 - 1 month ago 7x
Android Question

Delete all paired bluetooth devices on Android

I would like to delete paired bluetooth low energy devices with names that start with "ABC" on an Android phone programatically.

I am using Android studio.


To unpair all devices use this code

Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
        if (pairedDevices.size() > 0) {
            for (BluetoothDevice device : pairedDevices) {
                try {
                    Method m = device.getClass()
                            .getMethod("removeBond", (Class[]) null);
                    m.invoke(device, (Object[]) null);
                } catch (Exception e) {
                    Log.e("fail", e.getMessage());