Android Question [SOLVED] Can not connect to sqlite db under lollipop...

Luis Felipe

Member
Licensed User
Longtime User
Hi everyone,
My problem is that my app I made and was working under Android 4.2.2 with the 2 tablets I got, now is not working with my new smartphone : the difference ? it's running under Android 5.0.2.
When I compile (debug o release mode) I got this error message :
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
it stops on the line of code with the SQL.Initialize:
B4X:
        If File.Exists(File.DirDefaultExternal & "/Encuestas", "latbusdev.db") = False Then
        'File.Delete(File.DirRootExternal & "/Encuestas", "latbusdev.db") ' only for testing, removes the database
            SQL1.Initialize(File.DirDefaultExternal & "/Encuestas", "latbusdev.db", True)
            CreateDataBases
        'check if the database already exists
        Else
            'if not, initialize it
            SQL1.Initialize(File.DirDefaultExternal & "/Encuestas", "latbusdev.db", True)
            'and create it
           
        End If
The other big difference with my previous device is that the new one has no sdcard slot.
I updated the path configuration to C:\Android\platforms\android-21\android.jar.
I tried with DirInternal and testing If File.ExternalWritable = True but no...
There are a couple of days that I'm testing everything I can imagine but nothing is working : any help is apreciated.
Of course I'm in debugging mode with this Lollipop device.
Thanx in advance.
 

Luis Felipe

Member
Licensed User
Longtime User
Which line fails?

Are you creating this folder if it doesn't already exist?

The third one Erel, that one : "SQL1.Initialize(File.DirDefaultExternal & "/Encuestas", "latbusdev.db", True)"

Here is my whole code for my Activity_Create :

B4X:
Sub Activity_Create(FirstTime As Boolean)
   
    If FirstTime Then
    Log(File.DirInternal)
   
        '---Me conecto al servidor FTP y descargo los archivos necesarios para la bdd de los inspectores / conductores---
        FTP.Initialize("FTP", "xxx.xxx.xx.x", 21, "[email protected]", "xxxx")
        FTP.PassiveMode = True
        downloadcount = 0
        FTP.DownloadFile("/encuestas/tconductores.txt", False, File.DirInternal & "/Encuestas", "tconductores.txt")
       
'    If File.ExternalWritable = True Then
        If File.Exists(File.DirInternal & "/Encuestas", "latbusdev.db") = False Then
            'File.Delete(File.DirRootExternal & "/Encuestas", "latbusdev.db") ' only for testing, removes the database
            SQL1.Initialize(File.DirInternal & "/Encuestas", "latbusdev.db", True)
            CreateDataBases
        'check if the database already exists
        Else
            'if not, initialize it
            SQL1.Initialize(File.DirInternal & "/Encuestas", "latbusdev.db", True)
            'and create it
           
        End If
   
    End If
                Activity.LoadLayout("MenuPrincipal_NewLogo")
End Sub
 
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
Thank you Erel. That part is now working. But now my layout is not showing on screen. Why ? that's true that my app was running before on tablets but I did not do anything to prevent running it on smartphone. Is it related to the Designer ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
But now my layout is not showing on screen. Why ? that's true that my app was running before on tablets but I did not do anything to prevent running it on smartphone. Is it related to the Designer ?
Please start a new thread for this question. Make sure to provide more information.
 
Upvote 0
Top