public boolean isKeyInUse(@NonNull final MeshKey meshKey) {
        // We should not allow deleting a network key that is bound to an application key.
        // This would require deleting the application key that's bound to this network key before deleting network key.
        if (meshKey instanceof NetworkKey) {
            for (ApplicationKey applicationKey : appKeys) {
                if (meshKey.getKeyIndex() == applicationKey.getBoundNetKeyIndex()) {
                    throw new IllegalArgumentException("Please unbind " + meshKey.name + " from the " + applicationKey.name + " or delete the bound " + applicationKey.name + " first.");
                }
            }
        }

        for (ProvisionedMeshNode node : nodes) {
            if (!node.getUuid().equalsIgnoreCase(getSelectedProvisioner().getProvisionerUuid())) {
                final int index = meshKey.getKeyIndex();
                //We need to check if a key index is in use by checking in the added net/app key indexes
                if (meshKey instanceof ApplicationKey) {
                    return MeshParserUtils.isNodeKeyExists(node.getAddedAppKeys(), index);
                } else {
                    return MeshParserUtils.isNodeKeyExists(node.getAddedNetKeys(), index);
                }
            }
        }
        return false;
    }
Checks if the app key is in use.

<p>
This will check if the specified app key is added to a node other than the selected provisioner node
</p>

@param meshKey {@link MeshKey}
mesh/src/main/java/no/nordicsemi/android/mesh/BaseMeshNetwork.java