Android Question SQLite tables to ListView (replace text)

vdudukov

Member
Licensed User
Longtime User
Hello again!

I have a little problem with My tables in SQLite database. Well, I have a one SQLite database with lot of table names. Example 20_2013, 21_2013, 22_2013 etc. I want to load all these tables in ListView but without this sign "_" example 20 2013 not 20_2013. I create this function to load all tables from SQLite database, but i dont know how to replace "_" only in ListView, not in SQLite database because it must be with "_" in SQLdatabase. I use DBUtils.



DBUtils.ExecuteListView(database, "SELECT name FROM sqlite_master WHERE type = 'table'", Null, 0, db_table, False)


Thank You All :)
 

Merlot2309

Active Member
Licensed User
Longtime User
Hello,

You can use a string var, e.g.
Dim day as string
day = DBUtils.ExecuteListView(database, "SELECT name FROM sqlite_master WHERE type = 'table'", Null, 0, db_table, False)
day = day.Replace("_", " ")

Success
 
Upvote 0

devlei

Active Member
Licensed User
Longtime User
Try it directly with SQLite - something like (untested code):
B4X:
    Dim cur As Cursor
    Dim sqlDB As SQL
    Dim day As String
    Dim strQuery As String
    'ListView1 is from layout
   
    strQuery = "SELECT name FROM sqlite_master WHERE type = 'table'"
    sqlDB.BeginTransaction
    Try
        cur = sqlDB.ExecQuery(strQuery)
        For i = 0 To cur.RowCount - 1
            cur.Position = i
            day = cur.GetString("day")
            day = day.Replace("_", " ")
            ListView1.AddSingleLine2(day, day)
        Next
        sqlDB.TransactionSuccessful
    Catch
        Msgbox(LastException.Message, "Fill ListView Error")
    End Try
    sqlDB.EndTransaction
 
Upvote 0

vdudukov

Member
Licensed User
Longtime User
Try it directly with SQLite - something like (untested code):
B4X:
    Dim cur As Cursor
    Dim sqlDB As SQL
    Dim day As String
    Dim strQuery As String
    'ListView1 is from layout
  
    strQuery = "SELECT name FROM sqlite_master WHERE type = 'table'"
    sqlDB.BeginTransaction
    Try
        cur = sqlDB.ExecQuery(strQuery)
        For i = 0 To cur.RowCount - 1
            cur.Position = i
            day = cur.GetString("day")
            day = day.Replace("_", " ")
            ListView1.AddSingleLine2(day, day)
        Next
        sqlDB.TransactionSuccessful
    Catch
        Msgbox(LastException.Message, "Fill ListView Error")
    End Try
    sqlDB.EndTransaction
Oeps, I missed the DBUtils.

No problem, thanks anyway :)
 
Upvote 0

vdudukov

Member
Licensed User
Longtime User
Try it directly with SQLite - something like (untested code):
B4X:
    Dim cur As Cursor
    Dim sqlDB As SQL
    Dim day As String
    Dim strQuery As String
    'ListView1 is from layout
  
    strQuery = "SELECT name FROM sqlite_master WHERE type = 'table'"
    sqlDB.BeginTransaction
    Try
        cur = sqlDB.ExecQuery(strQuery)
        For i = 0 To cur.RowCount - 1
            cur.Position = i
            day = cur.GetString("day")
            day = day.Replace("_", " ")
            ListView1.AddSingleLine2(day, day)
        Next
        sqlDB.TransactionSuccessful
    Catch
        Msgbox(LastException.Message, "Fill ListView Error")
    End Try
    sqlDB.EndTransaction

Thank You :)
 
Upvote 0
Top