如何将现有的数据库.apk文件? [英] How to put existing database in the .apk file?
问题描述
我有prebuild的数据库主要是字符串对象。我想知道如何放入我的apk文件,因此数据库将在用户安装数据库时创建。
I have prebuild database of mostly string objects. I want to know how to put in my apk file so the database will be already created when the user installs the database.
推荐答案
我找到了一个很好的例子:使用你的在Android应用程序中自己的SQLite数据库
I found a good example of this: Using your own SQLite database in Android applications
基本上,您将创建的数据库导出为sql文件并将其存储在assets文件夹中。
在第一个程序开始,你导入文件的数据到你的最终数据库。
Basically, you export the created database as an sql-file and store it in the assets-folder. On the first program start, you import the data of the file into your final database.
我认为这是最好的方法,但你的数据将在那里在apk和db中两次,使用更多的存储空间。
I think it's the best approach, however your data will be there twice in the apk and the db, using some more storage space.
这篇关于如何将现有的数据库.apk文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!