B4i Library [module] DBUtils

Latest version available here: https://www.b4x.com/android/forum/threads/b4x-dbutils-2.81280/

B4i implementation of DBUtils: http://www.basic4ppc.com/android/forum/threads/8475/#content


DBUtils v1.10 - CreateTable now accepts two lists instead of a map for the columns and their types. The reason for this is that maps in B4i do not preserve the order and the order of columns can be important. Note that the updated CreateTable sub can be copied as is to B4A.


  • DBUtils.zip
    8.3 KB · Views: 205
Last edited:


Active Member
Licensed User
Hi @Erel , I want to notify a probably "Bug" in the Module.

As you stated in the files and folders, thenon-user generated persistent files should be stored in the DirLibrary, not in the DirDocuments as in the current implementation of DBUtils.

The problem is when you implement some functionality that require user generated files, for example, if you use UIFileSharingEnabled, then, the databases will be accesible to the user.

Is this correct or maybe I misundertood the DirLibrary function?



Active Member
Licensed User
Missing ExecuteMapList ?

There is a ExecuteMemoryMap, but it doesn't return maps

Sorry , ExecuteMapList was something I added in B4A.
Last edited:


Active Member
Licensed User
Here is the B4I code for ExecuteMapList

'Executes the query and returns a List of Maps with the column names as the keys 
'The keys are lower cased.
'Returns an uninitialized list if no results found.
Sub ExecuteMapList(SQL As SQL, Query As String, StringArgs() As String, Limit As Int) As List ' ******* RVP Added
    Dim rs As ResultSet = SQL.ExecQuery2(Query, StringArgs)
    Log("ExecuteMapList: " & Query)
    Dim TableList As List
    Dim count As Int = 0
    Do While rs.NextRow
        If     TableList.IsInitialized = False Then TableList.Initialize
        count = count+1
        If count <= Limit Or Limit = 0 Then
            Dim res As Map
            Dim values(rs.ColumnCount) As String
            For col = 0 To rs.ColumnCount - 1
                    res.Put(rs.GetColumnName(col).ToLowerCase, rs.GetString2(col))
                    Dim  byt() As Byte: byt  = rs.GetBlob2(col)
                    res.Put(rs.GetColumnName(col).ToLowerCase, BytesToString(byt,0,byt.Length,"UTF8"))
                End Try
        End If
    Return TableList
End Sub
Last edited:


Active Member
Licensed User