I know its basic task but I don't have luck with completing it.
I would need basic sample in using existing SQLite database in program.
I have DButilis included in my project also vicevi.db is under my project folder,
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim dbName="vicevi.db"
'DBUtils.CopyDBFromAssets(dbName)
If FirstTime Then
SQL.Initialize(File.DirRootExternal, dbName, True)
End If
Activity.LoadLayout("Layout1")
Dim ListView1 As ListView
ListView1.Initialize("ListView1")
DBUtils.ExecuteListView(SQL, "SELECT text FROM vic", Null, 0, ListView1, True)
End Sub
"an error has occured in line 20 SQL.initialize....unable to open database file"
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout1")
Dim dbName="vicevi.db"
If FirstTime Then
Dim db=DBUtils.CopyDBFromAssets(dbName)
SQL1.Initialize (db, dbName, True)
End If
'If FirstTime Then
' SQL.Initialize(File.DirRootExternal, dbName, True)
'End If
Dim ListView1 As ListView
ListView1.Initialize("ListView1")
DBUtils.ExecuteListView(SQL1, "SELECT text FROM vic", Null, 0, ListView1, False)
End Sub
I see listview is populated in code but NOTHING is shown in the screen !?! :sign0163:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout1")
Dim dbName="vicevi.db"
If FirstTime Then
Dim db=DBUtils.CopyDBFromAssets(dbName)
SQL1.Initialize (db, dbName, True)
End If
DBUtils.ExecuteListView(SQL1, "SELECT text FROM vic", Null, 0, ListView1,False)
End Sub
Now my next concern is that there is no much space in listview to show whole text for an item.
Is there a way to set listview item to auto height
I recommend you to use CustomListView instead of ListView. It will require to modify DBUtils however it will show the items with the height based on the text.