Android Question Database in dirassets not found

Discussion in 'Android Questions' started by Bernaert Dominique, Feb 8, 2018.

  1. Bernaert Dominique

    Bernaert Dominique Member Licensed User

    Hello,

    I'm trying to copy a database from the assets to the device, but I'm getting an error FileNotFoundException.
    The db file is in the files manager.
    I use the command

    Code:
    File.Copy(File.DirAssets, DBFileName, DBFileDir, DBFileName)
    I declared the following variables:

    Code:
    Public DBFileName = "kassa.db" As String
    Public DBFileDir = File.DirDefaultExternal As String
    Any idea?

    Thx,

    Dominique
     
  2. Bernaert Dominique

    Bernaert Dominique Member Licensed User

    Some more info.
    It worked perfectly when debugging.
    I changed the key from the debug key to a private key and the problem started.
    I also had this when i changed the package name.
     
  3. davidvidasoft

    davidvidasoft Member Licensed User

    I may not be able to help you with the current problem but I can recommend you to use the DBUtils2 module and you can get it here. With it you can set your sqlite database (after adding your database file through the Files Tab in B4A) with these commands:
    Code:
    Sub Process_Globals
        
    Dim SQL As SQL
        .
        .
        .
    End Sub

    .
    .
    .

    Sub 
        
    Dim DBFileName As String = "kassa.db"
        
    Dim DBFileDir As String = DBUtils.CopyDBFromAssets(DBFileName) 'This method returns the FileDir of the db
        SQL.Initialize(DBFileDir, DBFileName, False)
        .
        .
        .
    End Sub
     
    Last edited: Feb 8, 2018
    Erel likes this.
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