greenDAO icon indicating copy to clipboard operation
greenDAO copied to clipboard

I want to use the JSON1 Module inside the SQLitedabase

Open naitbrahim opened this issue 4 years ago • 3 comments

Hello there,

First of all, I want to thank you for your work, these tools are awesome, keep up the good job !

My issue is that the JSON1 module is not activated by default in the SQLiteDatabase that Android embeds in their OS.

I looked for a solution, the only thing I found is to embed my own SQLite version inside the project. this is what I've done (using NDK to compile it, etc..).

Now my question, is how to force Greendao to use this Database instead of the standard one ?

NB : this is where I took the SQLite database => https://www.sqlite.org/android/doc/trunk/www/install.wiki#buildnative

Thank you for your time and efforts,

Kindly regards.

naitbrahim avatar Jan 18 '21 12:01 naitbrahim

You can supply any database that satisfies the Database interface requirements to DaoMaster(db). Does that not work for you?

https://github.com/greenrobot-team/greenrobot-examples/blob/master/greendao/app/src/main/java/com/example/greendao/ExampleApp.java

greenrobot-team avatar Jan 19 '21 13:01 greenrobot-team

How can I do that ? I have an SQLiteDatabase class that implements Database interface from Greendao but I cannot override onCreate with this one.

@Override public void onCreate(org.sqlite.database.sqlite.SQLiteDatabase db) { super.onCreate(db); }

EDIT : What I want to replace is this : "import org.greenrobot.greendao.database.Database" by this one : "import org.sqlite.database.sqlite.SQLiteDatabase"

The last one implements already the Database interface. But I cannot see how I can do it.

Thank you in advance for your help

naitbrahim avatar Jan 19 '21 14:01 naitbrahim

You can write a wrapper/helper class similar to DatabaseOpenHelper.

greenrobot-team avatar Jan 25 '21 09:01 greenrobot-team