Android Question Database in dirassets not found

Bernaert Dominique

Member
Licensed User
Longtime 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

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

B4X:
Public DBFileName = "kassa.db" As String
Public DBFileDir = File.DirDefaultExternal As String

Any idea?

Thx,

Dominique
 

Bernaert Dominique

Member
Licensed User
Longtime 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.
 
Upvote 0

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:
B4X:
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:
Upvote 0
Top