With this UUID generator you will not have problems with duplicates, in Java 11 or higher it generates version 4.
ref.
developer.apple.com
B4X:
Public Sub UUID As String
#If B4i
Dim no As NativeObject
Return no.Initialize("NSUUID").RunMethod("UUID", Null).RunMethod("UUIDString", Null).AsString
#Else
Dim jo As JavaObject
Return jo.InitializeStatic("java.util.UUID").RunMethod("randomUUID", Null)
#End If
End Sub
ref.
NSUUID | Apple Developer Documentation
An object representing a universally unique value that bridges to ; use when you need reference semantics or other Foundation-specific behavior.