Android Question B4A DBUtils.COPYDB

JonnyCav

Member
I am trying to make a backup of my database using

Code: Copy
Private Sub btnBACKUPDatabase_Click
Dim dbd As String
dbd = DBUtils.GetDBFolder
Log(dbd)
DBUtils.CopyDBFromAssets("SWSU.db")
    DBUtils.cop
End Sub

But the file I can access (via my PC) only seems to show the records in the tables as they were when the database was first loaded.

My app works perfectly (updated records etc) but when I use this command it does not show updates/inserts.

Am I missing something?

Thanks for any pointers.
 
Solution
Code: Copy
File.Copy(DBFileDir, DBFileName, backupdir, DBFileBackup)
Log(File.Exists( backupdir, DBFileBackup))
It will return true.

Code: Copy
shared = rp.GetSafeDirDefaultExternal("shared")
Switch to FileProvider
Thanks. I understand.

So I have tried this:

Code: Copy
    Dim DBFileDir As String       
    DBFileDir = File.DirInternal
    Dim backupdir As String
    backupdir = Starter.shared
    Dim DBFileName As String   
    DBFileName = "SWSU.db"
    Dim DBFileBackup As String       
    DBFileBackup = "SWSUBACK.bak"

    File.Copy(DBFileDir, DBFileName, backupdir, DBFileBackup)

In my 'Starter' I have:

B4X: Copy
    sql.Initialize(File.DirInternal,"SWSU.db",True)
    
    shared = rp.GetSafeDirDefaultExternal("shared")

But despite the code running without error, no file is created.

Why might this be?
 
Upvote 0
Back
Top