Android Question renames the db with .bak extension

Discussion in 'Android Questions' started by Roberto P., Feb 27, 2015.

  1. Roberto P.

    Roberto P. Well-Known Member Licensed 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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you post the code that manages the db file?
     
  3. Roberto P.

    Roberto P. Well-Known Member Licensed User

    Code:
    CopyFileFromAssetToInternal(sDBName)
        
        sDBRoot    =    GetTargetInternalDir
     
      m_DB.Initialize(sDBRoot, sDBName)


    Sub CopyFileFromAssetToInternal(aFileName As StringAs 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: Mar 1, 2015
  4. DonManfred

    DonManfred Expert Licensed User

    How long are you here, ha?
    USE CODE TAGS WHEN POSTING CODE!
     
    KZero and thedesolatesoul like this.
  5. Roberto P.

    Roberto P. Well-Known Member Licensed User

    I was distracted. thank you
     
    thedesolatesoul likes this.
  6. DonManfred

    DonManfred Expert Licensed User

    Thank you
     
    thedesolatesoul likes this.
  7. Erel

    Erel Administrator Staff Member Licensed User

    Note that you can use DBUtils.CopyDBFromAssets instead of this code.

    I never encountered such case. Can you reproduce it? Try to delete the files and run it again.
     
  8. Roberto P.

    Roberto P. Well-Known Member Licensed 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
     
  9. Reviewnow

    Reviewnow Active Member Licensed 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
     
  10. Roberto P.

    Roberto P. Well-Known Member Licensed User

    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
     
  11. parijs

    parijs Active Member Licensed User

    I have the same Tablet Galax II and OS 4.22.
    and never a problem with SqlLite
     
  12. Roberto P.

    Roberto P. Well-Known Member Licensed 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
     
  13. parijs

    parijs Active Member Licensed User

    Hi Roberto,
    My destination folders are not readonly.
    Do you make the dbase externally?
    Can you make a stripped app for testing?
     
  14. Roberto P.

    Roberto P. Well-Known Member Licensed User

    yes, I create db externally and never had problems!
     
  15. parijs

    parijs Active Member Licensed 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?

    Code:
    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
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice