How to create database in assets folder using greendao

I have created the database and populate it. and put back it in the emulator. But problem come when I have to make the Apk. Then I realize that I have to put database in the apk and to ship with it.

So I searched for it and got the answer and that is to put the database in the assets folder. So the procedure some posts over her suggested could be applicable when i have been making my own database But I am using greendao.

So here comes the problem , So please any one know how to create or use database from the assets folder Using greendao ????

Please tell me the way How can I achieve this. Any piece of code would be appreciated.


You can't write to assets. Although, if you want to normally use DB from assets, you should copy database files to some normal directory like getCacheDir() and return DB from sqlite open helper


are you trying to pre-populate the DB?

what seems to be the issue? you can either create a task to do after creating your Session Object or use the SqliteOpenHelper class to inject the data once the DB is created. however, this is usually a very bad idea.

链接地址: http://www.djcxy.com/p/74584.html

上一篇: 如何使用预填充数据库与真实设备

下一篇: 如何使用greendao在资产文件夹中创建数据库