如何Android的访问包括在资产的文件夹中的SQLite数据库 [英] How does android access a sqlite database included in the assets folder
问题描述
我已经有一个SQLite数据库。我把我的项目在资产
文件夹。我读了Android文档。它说,在Android的所有数据库,路径是数据/数据/ pack_name /数据库名称
。
I already have a SQLite database. I put it in the assets
folder of my project. I read the Android documentation. It said that for all the databases in Android, the path is data/data/pack_name/database_name
.
这让我困惑。我只是把它放在了资产
文件夹中,这样的路径是数据/数据/资产/数据库名称
?
This confused me. I just placed it in the assets
folder, so the path is data/data/assets/database_name
?
推荐答案
包名称不是项目名称,包名的命名空间。从安东尼的链接。
The package name is not the project name, the package name is the namespace. From Anthony's link.
记住要改变YOUR_PACKAGE 您的应用程序包的命名空间 (即:com.examplename.myapp)在 DB_PATH字符串。
Remember to change the "YOUR_PACKAGE" to your application package namespace (i.e: com.examplename.myapp) in the DB_PATH string.
例如,从的Hello World教程,项目名称为 HelloAndroid
但包名为 com.example.helloandroid
For example, from the Hello World tutorial, the project name is HelloAndroid
but the package name is com.example.helloandroid
如果该应用程序有一个数据库,它会被保存在数据/数据/ com.example.helloandroid /数据库
If this application had a database, it would be stored at data/data/com.example.helloandroid/database
要看看它是如何在其他应用程序,你就可以开始你的模拟器。在菜单栏上你有你的AVD的名字(我认为这代表着Android虚拟设备)。对矿井它的avdessay:5554
To see how it is for the other applications you can start your emulator. On the menu bar you have your avd's name (I think it stands for Android Virtual Device). On mine it s "avdessay:5554"
(在Linux)在命令行中键入:
(On Linux) From command line, type:
ADB -s模拟器-5554外壳
您必须通过任何端口,你正在使用,以取代5554。
You have to replace 5554 by whatever port you are using.
如果您有命令提示符#你可以输入:
if you have the command prompt '#' you can type:
CD数据/数据
在那里,你将看到eveything是在包名的形式。
There, you will see that eveything is in a form of a package name.
More info here
这篇关于如何Android的访问包括在资产的文件夹中的SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!