public boolean updateNetKey(@NonNull final NetworkKey networkKey, @NonNull final String newNetKey) throws IllegalArgumentException {
        if (MeshParserUtils.validateKeyInput(newNetKey)) {
            final byte[] key = MeshParserUtils.toByteArray(newNetKey);
            if (isNetKeyExists(key)) {
                throw new IllegalArgumentException("Net key value is already in use.");
            }

            final int keyIndex = networkKey.getKeyIndex();
            final NetworkKey netKey = getNetKey(keyIndex);
            if (!isKeyInUse(netKey)) {
                //We check if the contents of the key are the same
                //This will return true only if the key index and the key are the same
                if (netKey.equals(networkKey)) {
                    netKey.setKey(key);
                    return updateMeshKey(netKey);
                } else {
                    return false;
                }
            } else {
                throw new IllegalArgumentException("Unable to update a network key that's already in use. ");
            }
        }
        return false;
    }
Update a network key with the given 16-byte hexadecimal string in the mesh network.

<p>
Updating a NetworkKey's key value requires initiating a Key Refresh Procedure. A NetworkKey that's in use
would require a Key Refresh Procedure to update it's key contents. However a NetworkKey that's not in could
be updated without this procedure. If the key is in use, call {@link #distributeNetKey(NetworkKey, byte[])}
to initiate the Key Refresh Procedure.
</p>

@param networkKey Network key
@param newNetKey  16-byte hexadecimal string
@throws IllegalArgumentException if the key is already in use
mesh/src/main/java/no/nordicsemi/android/mesh/BaseMeshNetwork.java