如何在 Eclipse IDE 中导入 SQLite 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4296519/
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 import SQLite database in Eclipse IDE
提问by sean
I am creating an Android Application and I recently downloaded a SQLite Database Browser. I have created a database which has 3 tables. Now I'm wondering on how to import the created database into Eclpise IDE.
我正在创建一个 Android 应用程序,我最近下载了一个 SQLite 数据库浏览器。我创建了一个包含 3 个表的数据库。现在我想知道如何将创建的数据库导入 Eclpise IDE。
I hope someone could help..
我希望有人可以帮助..
回答by Wroclai
You have to put your SQLiteDatabase
file inside the assets
folder of your project.
您必须将SQLiteDatabase
文件放在assets
项目的文件夹中。
回答by Julian
Open the DDMSperspective in Eclipse. There you should have a tab saying File Explorer(remember to select your emulator device in the Devicestab). You can use this to browse to your database file on the emulator. The database should be located in \data\data\[name_of_your_app]\databases. You can then select the database file (.db) and copy it to a local folder (there is a Pull a file from the devicebutton in the upper right corner of this tab).
在 Eclipse 中打开DDMS透视图。在那里你应该有一个选项卡,上面写着文件资源管理器(记住在设备选项卡中选择你的模拟器设备)。您可以使用它在模拟器上浏览到您的数据库文件。数据库应位于\data\data\[name_of_your_app]\databases。然后,您可以选择数据库文件 (.db) 并将其复制到本地文件夹(此选项卡的右上角有一个从设备中提取文件按钮)。
Also note that this is only possible on an emulator, since you're not allowed to browse the content on a real device this way.
另请注意,这只能在模拟器上进行,因为您不允许以这种方式在真实设备上浏览内容。