Android的SQLite的外部导入/创建 [英] Android SQlite external import/create
问题描述
我有来自外部的SQLite管理问题的数据库。我想在我的应用程序第一次运行时创建一个数据库。
I have a database of questions from an external SQlite manager. I would like to create a database on the first run of my app.
是写作code线hundereds这种可能呢?
Is this possible instead of writing hundereds of lines of code?
推荐答案
是的,这是可能的。你可以把SQLite的文件在你的Android 资产文件夹项目(或下载点播),并将其复制到安装的应用程序的数据库文件夹。
Yes, this is possible. You can put the SQLite file in the assets folder of your Android project (or download it on demand) and copy it to the database folder of the installed app.
有一个教程解释所有的neccesary步骤可以找到的这里。
A tutorial explaining all the neccesary steps can be found here.
但是请注意,如果您包含数据库文件到您的APK,它将消耗比绝对必要的磁盘空间的两倍(因为它会存在两次,作为资产和可用的数据库)。根据数据库的大小,它可能是preferable下载它嵌入到APK它代替。
Note however that if you include the database file into your APK, it will consume twice the disk space than absolutely necessary (since it will exist twice, as asset and as usable database). Depending on the size of your database, it might be preferable to download it instead of embedding it into the APK.
请注意此外,这之前的Android 2.3,任何COM $ P $超过1 MB的uncom pressed大小pssed资产文件不能从APK读取(以及任何资产将COM pressed通过默认值)。
Note furthermore, that prior to Android 2.3, any compressed asset file with an uncompressed size of over 1 MB cannot be read from the APK (and any asset will be compressed by default).
这篇关于Android的SQLite的外部导入/创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!