如何以及在何处将 sqlite(.db) 文件添加到 android 项目中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10579798/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How and where to add sqlite(.db) file in to an android project
提问by sree_iphonedev
I am new to Android. Now, I am trying to work with database. I got many tutorials for manipulating Sqlite database operations. But my doubt is that where should I add the .db file in to the application. In package explorer window of IDE, under which folder group I need to add the .db file? I hope you understand my question.
我是安卓新手。现在,我正在尝试使用数据库。我得到了很多操作 Sqlite 数据库操作的教程。但我怀疑我应该在哪里将 .db 文件添加到应用程序中。在IDE的包资源管理器窗口中,我需要在哪个文件夹组下添加.db文件?我希望你明白我的问题。
Thanks in advance.
提前致谢。
采纳答案by MAC
If you already have .dbfile then put that file in assetsfolder or rawfolder
如果您已经有.db文件,则将该文件放在assets文件夹或raw文件夹中
Then you have to copy that file at path /your.package.name/data/datadirectory for further use.
然后您必须将该文件复制到路径/your.package.name/data/data目录以供进一步使用。
Otherwise you can create new database using code... Hope this will help you ...!
否则,您可以使用代码创建新数据库...希望这对您有所帮助...!
see thisexample....
看这个例子....