Sqlite db in assets folder

北城以北 提交于 2020-01-24 13:03:09

问题


There is problem in understanding the concept.

I am creating a SQLite sample app in android. currently i am using the path /data/data/packname/databases to store the database.

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.

Reason:- I want to see database files onupgrade().

I found lots of question related that but not satisfied with the answers .

Any Suggestions


回答1:


You can't copy anything into your assets folder inside your APK, because APKs can't be changed at runtime.

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.




回答2:


You can copy data base from assets folder to your emulator or device at run time. If you want to see your updated data base you have to fetch data base from emulator to your system from

data/data/packagename/databases

I think it is not possible to change data at run time in assets folder. I tried to do that but not success-ed in that. If you found solution post it, so that i can use it.




回答3:


What i have understanding from your question is your little misconception with how can see SQLite database, so if you have to see your database file then you do not need to save your database in your assets folder.Database file is in the data>data>your application package>database. You can push file from your device and see it. So if you have to see your database then please follow my answer of this question. Where i have briefly describe how can you see you database.



来源:https://stackoverflow.com/questions/15401177/sqlite-db-in-assets-folder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!