资产文件夹中的 Sqlite 数据库 [英] Sqlite db in assets folder
问题描述
概念理解有问题.
我正在 android 中创建一个 SQLite 示例应用程序.目前我正在使用路径 /data/data/packname/databases
来存储数据库.
I am creating a SQLite sample app in android. currently i am using the path /data/data/packname/databases
to store the database.
并且我的资产文件夹中没有任何内容,我想知道如何将数据库从我的内部路径复制到 assets
文件夹中.
and there is nothing in my assets folder, i want to know how can i copy the database from my internal path in to assets
folder.
原因:- 我想查看数据库文件onupgrade()
.
Reason:- I want to see database files onupgrade()
.
我发现了很多相关的问题,但对答案并不满意.
I found lots of question related that but not satisfied with the answers .
任何建议
推荐答案
您无法将任何内容复制到 APK 内的 assets
文件夹中,因为无法在运行时更改 APK.
You can't copy anything into your assets
folder inside your APK, because APKs can't be changed at runtime.
>
做相反的事情,即在你的assets文件夹中打包一个数据库并写入磁盘,你可以使用这个项目:https://github.com/jgilfelt/android-sqlite-asset-helper您可以在开发时使用它,而不是运行时.
To do the opposite, that is, package a database in you assets folder and write it to disk, you can use this project: https://github.com/jgilfelt/android-sqlite-asset-helper You use this at development time, not runtime though.
这篇关于资产文件夹中的 Sqlite 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!