eclipse 如何将 Sqlite 数据库添加到我的项目中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18274207/
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 to add Sqlite database to my project?
提问by 1999493
I am working on (Quiz)Android Project. Now, I am trying to work with database. I got many tutorials for manipulating Sq-lite database operations. But my problem is where and how should I add the .db file in to the application. In package explorer of Eclipse IDE, under which folder group I need to add the .db file? and how to add question in my Sqlite database to my project.
我正在研究(测验)Android 项目。现在,我正在尝试使用数据库。我得到了很多操作 Sqllite 数据库操作的教程。但我的问题是我应该在哪里以及如何将 .db 文件添加到应用程序中。在Eclipse IDE的包资源管理器中,我需要在哪个文件夹组下添加.db文件?以及如何将我的 Sqlite 数据库中的问题添加到我的项目中。
Thanks in advance.
提前致谢。
采纳答案by Aravin
Creation of database ..
创建数据库..
See the following quiz demos it will create some idea to you.
请参阅以下测验演示,它将为您创造一些想法。
To refer the following for your requirement..
根据您的要求参考以下内容。
replace to button instead of radio button above link...
替换为按钮而不是链接上方的单选按钮...
quiz 3 link...
测验 3 链接...
回答by Harish Godara
Your db default path will be :
您的数据库默认路径将是:
//data/data/<Your-Application-Package-Name>/databases/<your-database-name>
You can put and open the database from wherever you like :
你可以从任何你喜欢的地方放置和打开数据库:
SQLiteDatabase.openDatabase("/sdcard/mydatabase.db", null, SQLiteDatabase.OPEN_READONLY);
回答by bofredo
SQLite builds the local database for you automatically. So you really have to do nothing at all. This makes sense as the app creates the database on your DEVICE and not on your workspace. Else another user wouldnt be able to use the app as he won't be able accessing a database in your workspace.
SQLite 会自动为您构建本地数据库。所以你真的什么都不用做。这是有道理的,因为应用程序在您的设备上而不是在您的工作区上创建数据库。否则另一个用户将无法使用该应用程序,因为他将无法访问您工作区中的数据库。