Android Question DBUtils.CopyDBFromAssets function

Bucky108

Member
Licensed User
Longtime User
I have added a SQLite database to the files folder of a project and when the DBUtils.CopyDBFromAssets function is called
(on the line File.Copy(File.DirAssets, FileName, TargetDir, FileName)
it errors out with the message:

java.io.FileNotFoundException: /data/user/0/b4a.example/files/virtual_assets/new.db: open failed: ENOENT (No such file or directory)

Can anyone suggest what the problem is?
 

Bucky108

Member
Licensed User
Longtime User
Apparently and oddly, the problem was with the file name. I renamed "new.db" to "contacts.db" and then DBUtils.CopyDBFromAssets worked.

Could this be a bug or are is there some kind of restriction with the file name of a SQLite DB file?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Unfortunately you don't give enough information.
How, exaxtly, looks like the line with DBUtils.CopyDBFromAssets("new.db") ?
It schould be:
DBDir = DBUtils.CopyDBFromAssets("new.db")
DBUtils.CopyDBFromAssets
retuns a string with the name of the directory.
DBDir should be declared somewhere as a string.
 
Upvote 0
Top