greenrobot / greenDAO

greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.
http://greenrobot.org/greendao/
12.63k stars 2.89k forks source link

I want to use the JSON1 Module inside the SQLitedabase #1065

Open naitbrahim opened 3 years ago

naitbrahim commented 3 years ago

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.

greenrobot-team commented 3 years ago

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

naitbrahim commented 3 years ago

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

greenrobot-team commented 3 years ago

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