@Override
    public boolean equals(@Nullable final Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj instanceof ApplicationKey) {
            final ApplicationKey appKey = (ApplicationKey) obj;

            return Arrays.equals(key, appKey.key) && keyIndex == appKey.keyIndex;
        } else if (obj instanceof NetworkKey) {
            final NetworkKey netKey = (NetworkKey) obj;

            return Arrays.equals(key, netKey.key) && keyIndex == netKey.keyIndex;
        }
        return false;
    }
Set the old key

@param oldKey old app key
mesh/src/main/java/no/nordicsemi/android/mesh/MeshKey.java