Android Question Cannot access File.DirInternal

barryhuntpinncomp

Member
Licensed User
I am trying to access a .sqllite3 database without success. This has been testing me for some hours.
I have B4A 10.2 installed and
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="29"/>

Any help would be much appreciated.

File_List.png


B4X:
Sub Process_Globals
    Private xui As XUI
    Public SQL1 As SQL
End Sub
Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    If FirstTime Then   
        Log(File.DirInternal)
        If File.Exists(File.DirInternal, "test.sqlite3") Then
            Log("Test OK")
            SQL1.Initialize(File.DirInternal, "test.sqlite3", True)
        Else
            Log("Test Missing")
        End If
    End If
End Sub

Logger connected to: samsung SM-G781B

----------------
/data/user/0/b4a.example/files
Test Missing
** Activity (main) Resume **
 

klaus

Expert
Licensed User
From your image, it looks like your file is not in File.DirInternal but in the directory you get with:
RuntimePermissions.GetSafeDirDefaultExternal("")

I am not sure if the extension ".sqlite3" is accepted.
Maybe, rename the file to "test.db".
 
Upvote 0

RichardN

Active Member
Licensed User
I think you can call an SQLite database whatever you like as long as the db engine finds the correct file format when it is initialised. This comes in useful if you want to deploy a database within an app package without making it obvious it is there. Just another form of obfuscation really.
 
  • Like
Reactions: eps
Upvote 0
Top