Android Question code 14 SQLITE_CANTOPEN

b2mvga

Member
Licensed User
Longtime User
Hi

I have a backup recovery routine, I unzip one zip file (containing the .DB database) and put this database in DirInternal folder.

B4X:
Sub DescompactaZip
    Dim zipa As ABZipUnzip
    If File.Exists(File.DirRootExternal & "/mgmobile/backup",NomeBanco) = True Then
        zipa.ABUnzip(File.DirRootExternal & "/mgmobile/backup/" & NomeBanco,File.DirRootExternal & "/mgmobile/backup")
        If File.Exists(File.DirRootExternal & "/mgmobile/backup","vemovel.db") = True Then
            SQL1.Close
            File.Copy(File.DirRootExternal & "/mgmobile/backup","vemovel.db",File.DirInternal,"vemovel.db")
            Msgbox("Backup Restaurado com sucesso","OK")
            ExitApplication
        Else
            Msgbox("Arquivo vemovel.db não localizado na pasta backup","Atenção")
        End If
    Else
        Msgbox("Não foi encontrado nenhum zip de backup na unidade externa, verifique","Não realizado")
    End If
End Sub

In 99% of devices works fine... in some devices (Like Motorola Moto X4, Motorola G7 Plus) I can´t recover backup... the routines work without error (the vemovel.db file is unziped on File.DirRootExternal & "/mgmobile/backup" folder normally, after copy vemovel.db file to DirIternal the app I close app with ExitApplication and when I reopen app I receive the message: code 14 SQLITE_CANTOPEN

The same backup restored on any samsung, LG, etc works fine...

I only receive this message in some Motorolas

My app is API=22

Any help please?

erro.jpeg


erro2.jpg
 
Last edited:

b2mvga

Member
Licensed User
Longtime User
Please upload a smaller image and post the error message as text.

Sorry Erel, next time I put smaller image and erros as text.

I solve motorola problem, In Main program after try open vemovel.db file (with sqlite error), I recover backup again before any initialize and works

My code in MAIN Before:

B4X:
    If SQL1.IsInitialized = False Then
            SQL1.Initialize(File.DirInternal, "vemovel.db", False)

My code in MAIN now:

B4X:
    If SQL1.IsInitialized = False Then
        Try
            SQL1.Initialize(File.DirInternal, "vemovel.db", False)
        Catch
            If File.Exists(File.DirRootExternal & "/mgmobile/backup","vemovel.db") = True Then
                File.Copy(File.DirRootExternal & "/mgmobile/backup","vemovel.db",File.DirInternal,"vemovel.db")
                SQL1.Initialize(File.DirInternal, "vemovel.db", False)
            End If
        End Try
    End If
 
Upvote 0
Top