Hello.
I'm developing an app that is intended to hide a button if the user is not an administrator. But it throws this exception:
Error occurred on line: 109 (main)
android.database.sqlite.SQLiteException: no such column: isadmin: , while compiling: SELECT isadmin FROM users WHERE login = ?
This is the code:
B4X:
Sub CheckPassword(Password As String, Login As String)
Dim Checkme As Boolean = False
oCursor = oSql.ExecQuery2("SELECT password FROM users WHERE login = ?", Array As String(Login))
If oCursor.RowCount <> 0 Then
oCursor.Position = 0
Dim Returnme As String = oCursor.GetString2(0)
If Password = Retorno Then
Checkme = True
Loggeduser = Login
oCursor = oSql.ExecQuery2("SELECT isadmin FROM users WHERE login = ?", Array As String(Login))
oCursor.Position = 0
Dim NoBool As Short = oCursor.GetInt2(0)
If NoBool = 0 Then
Isanadmin = 0
Else
Isanadmin = 1
End If
Else
Checkme = False
End If
Else
Checkme = False
End If
Return Checkme
End Sub
I don't know what was happening.
I had to rebuild the database and switch the NUMERIC fields to INTEGER (Using replace on Notepad, lol)
And then execute the query.
This problem is rare because i tried to rebuild the database several times and also i tried to wipe user data from the Device.
But this time i renamed the database and also switched the NUMERIC fields to INTEGER.
B4X:
Sub Activity_Create(FirstTime As Boolean)
If File.ExternalWritable Then
Route = File.DirDefaultExternal
Else
Route = File.DirInternal
End If
If File.Exists(Route,DBName) = False
File.Copy(File.DirAssets, DBName, Route, DBName)
End If
Activity.LoadLayout("Main")
Clock.Initialize("Clock", 1000)
If FirstTime = True Then
oSql.Initialize(Route, DBName, False)
Else
oSql.Close
oSql.Initialize(Route, DBName, False)
End If
End Sub
There is a bug in Android 2.2 that causes the files under File.DirDefaultExternal to be deleted when the app is reinstalled (on some devices). I don't know if this is the cause here however it is worth testing it with a different folder.