简体   繁体   English

可以将SQL文件导入Basic4Android吗?

[英]Can an SQL file be imported into Basic4Android?

I am trying to directly import an SQL file from a SQLite database into Basic4Android. 我正在尝试将SQLite从SQLite数据库直接导入Basic4Android。 I exported a .sql file and then I loaded the SQL file into the Basic4Android assets in the IDE. 我导出了.sql文件,然后将SQL文件加载到IDE中的Basic4Android资产中。

Then I put this in my Process_Globals 然后我把它放在我的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. File.DirAssets是只读的,也许不能从只读目录中使用SQL。 If that is the case then how else would I import an SQL file into the application. 如果是这种情况,那么我将如何将SQL文件导入应用程序。
  2. Possibly the databases are incompatible but I would think they should be compatible 可能数据库不兼容,但我认为它们应该兼容

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. 在任何文本编辑器中打开.sql文件,您将看到它是SQL语句的列表。

An SQLite database file is an entirely different format as you'll see if you open it in a text editor. 如果您在文本编辑器中打开SQLite数据库文件,则会看到完全不同的格式。

You do not need to export anything. 您无需导出任何内容。 Just copy the SQLite file to your project. 只需将SQLite文件复制到您的项目即可。

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. DBUtils可以帮助您完成此任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM