Hello all ...
I'm unable to make this function working. I have a big database where I want to add a UIDS table but no way. The myDb database is initialized in Starter Service_Create and this sub is called from Main on_create if firstTime.
I tried with KeyValueStore initialized just after myDb, it is working.
This UID is intended to be used with LicenseChecker. Is KVS more or less secure than SQL for that purpose?
Thanks.
I'm unable to make this function working. I have a big database where I want to add a UIDS table but no way. The myDb database is initialized in Starter Service_Create and this sub is called from Main on_create if firstTime.
B4X:
' Get user's UID.
Sub UID As String
Dim myUID, sqlStr As String
' Informations table
myDb.ExecNonQuery("CREATE TABLE IF NOT EXISTS UIDS (ID INTEGER PRIMARY KEY AUTOINCREMENT, UID TEXT)")
sqlStr = "SELECT count(*) FROM UIDS"
Dim cnt As Int = myDb.ExecQuerySingleResult(sqlStr)
If cnt = 0 Then ' <-- always = 0
myUID = su.EncodeUrl("_" & Rnd(1000000, 9999999) & "_", "UTF8")
sqlStr = "INSERT INTO UIDS (UID) VALUES ('" & myUID & "')"
myDb.ExecQuery(sqlStr)
End If
sqlStr = "SELECT UID FROM UIDS LIMIT 1"
myUID = myDb.ExecQuerySingleResult(sqlStr)
Return su.DecodeUrl(myUID, "UTF8")' <-- here myUID is Null
End Sub
I tried with KeyValueStore initialized just after myDb, it is working.
This UID is intended to be used with LicenseChecker. Is KVS more or less secure than SQL for that purpose?
Thanks.