Android Question DirInternal sqlite

sigster

Active Member
Licensed User
Longtime User
Hi
I was using DirRootExternal for the SQLite file with no problem now I change into DirInternal.

Sometimes when I open the app I don't get the data from SQLite file I need to open and close the app few time
until I get the date from SQLite file , It happens very often



B4X:
    If FirstTime Then
        
        If File.Exists(File.DirInternal, "color.db") Then
            Log("File OK")
            SQL1.Initialize(File.DirInternal, "color.db", False)
        Else
            File.Copy(File.DirAssets,"color.db",File.DirInternal,"color.db")
            Log("File Missing")
            SQL1.Initialize(File.DirInternal, "color.db", False)
        End If
    End If


B4X:
        Dim Cursor1 As Cursor
    Cursor1 = SQL1.ExecQuery("SELECT * FROM category ORDER BY category_name")   
    For i = 0 To Cursor1.RowCount - 1
        Cursor1.Position = i
        CLV1.AddTextItem(Cursor1.GetString("category_name"), Cursor1.GetString("category_name_ID"))
    Next
    Cursor1.Close
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Better:
B4X:
  If FirstTime Then
        If File.Exists(File.DirInternal, "color.db") Then
            Log("File OK")
        Else
            File.Copy(File.DirAssets,"color.db",File.DirInternal,"color.db")
            Log("File Missing")
        End If
         SQL1.Initialize(File.DirInternal, "color.db", False)
    End If

Your code looks correct. The problem is somewhere else.
 
Upvote 0
Top