Question

I am trying to directly import an SQL file from a SQLite database into Basic4Android. I exported a .sql file and then I loaded the SQL file into the Basic4Android assets in the IDE.

Then I put this in my Process_Globals

Dim access As SQL
access.Initialize(File.DirAssets,"example.sql",True)

However the application crashes immediately on load when I try to run this code.

There's two things that I think could be wrong:

  1. File.DirAssets is read-only and perhaps SQL can not be used from a read only directory. If that is the case then how else would I import an SQL file into the application.
  2. Possibly the databases are incompatible but I would think they should be compatible
Was it helpful?

Solution

You do not need to export anything. Just copy the SQLite file to your project.

As you wrote it is not possible to open a database that is located in the assets folder. You should first copy it to a writable location. DBUtils can help you with this task.

OTHER TIPS

I'm sure this is not possible.

Open the .sql file in any text editor and you'll see it's a list of SQL statements.

An SQLite database file is an entirely different format as you'll see if you open it in a text editor.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top