Good day. I am new to B4A and I want to create an application with SQLite database. I set up the DB Browser properly and added the sql file to the file manager in b4a. But the problem is I always encounter this error "android.database.sqlite.SQLiteException: no such table: user_table (code 1 SQLITE_ERROR): , while compiling: select * from user_table". Here is the code that i follow
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
If File.Exists(File.DirInternal,"sample_db.db")=False Then
File.Copy(File.DirAssets,"sample_db.db",File.DirInternal,"sample_db.db")
Else
sql.Initialize(File.DirInternal,"sample_db.db",True)
If sql.IsInitialized Then
Log("Database connection opened successfully.")
Else
Log("Failed to open database connection.")
End If
End If
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
Try
cursor=Starter.sql.ExecQuery("select * from user_table")
cursor.Position=0
Activity.Title=cursor.GetString("name")
cursor.Close
Catch
Log(LastException.Message)
End Try
End Sub