android - android如何访问 Assets 文件夹中包含的sqlite数据库

标签 android sqlite

我已经有一个 SQLite 数据库。我把它放在我项目的 assets 文件夹中。我阅读了 Android 文档。它说对于Android中的所有数据库,路径是data/data/pack_name/database_name

这让我很困惑。我只是放在assets文件夹下,所以路径是data/data/assets/database_name?

最佳答案

包名不是项目名,包名是命名空间。来自 Anthony 的链接。

Remember to change the "YOUR_PACKAGE" to your application package namespace (i.e: com.examplename.myapp) in the DB_PATH string.

例如,来自the Hello World tutorial ,项目名称是 HelloAndroid 但包名称是 com.example.helloandroid

如果这个应用程序有一个数据库,它将存储在 data/data/com.example.helloandroid/database

要查看其他应用程序的情况,您可以启动模拟器。在菜单栏上有您的 avd 名称(我认为它代表 Android Virtual Device)。我的是“avdessay:5554”

(在 Linux 上)从命令行输入:

adb -s emulator-5554 shell

您必须将 5554 替换为您正在使用的任何端口。

如果您有命令提示符“#”,您可以键入:

cd 数据/数据

在那里,你会看到一切都是包名的形式。

更多信息 here

关于android - android如何访问 Assets 文件夹中包含的sqlite数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2318784/

相关文章:

java - 无法更新 SQLite 数据库中的整数字段

android - Android Bitmap.getPixels()从BufferedImage.getRGB()返回不同的数据

SQLite3 : Insert BLOB with NULL characters in C++

android - 从 android shell 向数据库中插入行的有效方法?

database - SQLite3 : database not being saved

sqlite - 如何在 BlackBerry OS 4.5 中使用 SqLite?

android - recyclerview android中的多个 header

锁屏后调用Android onCreate

android - 如果已执行,则禁用一个按钮

android - ObjectAnimator 的一部分未与 API 级别 23 以下的 AnimationSet playTogether() 同时播放