Android Question renames the db with .bak extension

Roberto P.

Well-Known Member
Licensed User
Longtime User
I installed my app on a tablet that renames the db with .bak extension and create a new db empty! It 'happened to anyone? What can it be?
Thank You
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
B4X:
CopyFileFromAssetToInternal(sDBName)
    
    sDBRoot    =    GetTargetInternalDir
 
  m_DB.Initialize(sDBRoot, sDBName)


Sub CopyFileFromAssetToInternal(aFileName As String) As Boolean
 
    Dim TargetDir As String
 
    TargetDir = GetTargetInternalDir
     
    If File.Exists(TargetDir, aFileName) = False Then
        File.Copy(File.DirAssets, aFileName, TargetDir, aFileName)
    End If
 
End Sub

Sub GetTargetInternalDir() As String
 
    Dim TargetDir As String
 
    If File.ExternalWritable Then
        TargetDir = File.DirDefaultExternal
    Else  
        TargetDir = File.DirInternal
    End If 

    Log("Storage Internal Dir: " & TargetDir)
    Return TargetDir

End Sub
The problem occurred with Tablet Galax II and OS 4.22.
Here is the code
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
How long are you here, ha?
USE CODE TAGS WHEN POSTING CODE!
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
the problem occurs only with the tablet: I do not know if it's a problem I know the version of O.S. or more. I tried deleting the file, copy it by hand but the problem occurs when launching the app db is renamed
thanks
 
Upvote 0

Reviewnow

Active Member
Licensed User
Longtime User
Have you tried an alternate database file with the same end result ?
is it possible that your database is corrupt?
try recreating the database and table structure with no data and see if you get the same result

Just a few suggestions
Good Luck
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
Have you tried an alternate database file with the same end result ?
is it possible that your database is corrupt?
try recreating the database and table structure with no data and see if you get the same result

Just a few suggestions
Good Luck

I've tried everything! I think it's a problem of version SqlLite or tablet's operating system.
I can not understand how it is possible!
thank you
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
hello parijs
I thank you for the feedback.
And 'normal that the destination folder is readonly? Or the problem is the version of SqlLite?
Thank You
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
Hi Roberto,
My destination folders are not readonly.
Do you make the dbase externally?
Can you make a stripped app for testing?
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
yes, I create db externally and never had problems!
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
Do you use DBUtils lib in your app?
Would you try this with your own db dir and name to look if it works?

B4X:
If File.Exists(File.DirRootExternal, "Transmis/trasmis.db") = False Then
File.MakeDir(File.DirRootExternal,"Transmis")
File.Copy(File.DirAssets,"trasmis.db", File.DirRootExternal, "Transmis/trasmis")
End If
 
Upvote 0
Top