B4X:
Sub GenerateGUID As String
' Get date and scramble it
Dim d As Long = DateTime.Now
Dim sd As String = ScrambleDate(d) 'Shuffle method scrambles a string
' Generate random hex string
Dim hex As String = "0123456789abcdef"
Dim r As StringBuilder
r.Initialize
Dim i As Int
For i = 0 To 15
r.Append(hex.CharAt(Rnd(0, 15)))
Next
Dim f As String = File.DirInternal & "ids.txt"
If File.Exists(File.DirInternal,f) Then
Log("file exists")
'File already exists, read existing ID
Return File.ReadString(File.DirInternal,f)
Else
'File doesn't exist, save new ID
File.WriteString(File.DirInternal, "ids.txt", sd & r.ToString)
Return sd & r.ToString
End If
End Sub
the function File.Exists never finds the file so I get a new unique ID every single time a run the app