Using Android java Code in my Appium Test

I am new in the World of mobile Testing.

I am starting an App and testing it with appium Syntax. But i want to remove all Bluetooth Bindings before i start my Test. I found this Code for Android but i dont know how i can implement this in My Test.

public static void clearBondings() {
	Set<BluetoothDevice> bondedDevices = BluetoothAdapter
	try {
		Class<?> btDeviceInstance = Class.forName(BluetoothDevice.class
		Method removeBondMethod = btDeviceInstance.getMethod("removeBond");

		boolean cleared = false;
		for (BluetoothDevice bluetoothDevice : bondedDevices) {
			if(bluetoothDevice.getName().contains("OB_")) {
				String mac = bluetoothDevice.getAddress();

			cleared = true;


		if (!cleared) {
	} catch (Throwable th) {

I would be glad, if someone can help me. My Appium Code is also in Java