ormlite-android
ormlite-android copied to clipboard
Wrote Complete: Support Multi-DB within OpenHelperManager. Need PR?
Hi! I'm a Ormlite fan. We have many projects that use your products. Thanks a million!
Note: My English is not good. So I would speak as briefly as possible and use simple words.
Before
We used to refer your example HelloAndroidTwoDbs to suppport multi-db.
In addition, lacking any better idea :-(
After
Later, I tried to modify OpenHelerManager.
I created two new classes: OpenHelper
and OpenHelpers
. The role of OpenHelper
is almost the same as the original OpenHelperManager
, except became into a instance. OpenHelpers is used to manage all of the OpenHelper.
Just like:
Dao<City, Long> dao = OpenHelpers.getDao(context, CityHelper.class, City.class);
OpenHelpers.release(CityHelper.class);
These OrmLiteSqliteOpenHelper(s) match the ones all over the New OpenHelper(s). Fully comply with the rules!
Other usage:
CityHelper helper = OpenHelpers.getOrmliteHelper(context, CityHelper.class);
OpenHelper openHelper = OpenHelpers.get(CityHelper.class);
Advantage
It's very fruitful. These classes has approached the issue in a practical way. You won't need to reference any example, rewrite any extra code. Just need to use that one.
Testing
I wrote some simple unit-test code, have long time for our project. All operators have to verify is passed, ease of use!
Ending
If @j256 want to use these code, please tell me. I will improve the unit test, and PR to your project.
Awaiting for your reply. Thank you very much!
CC: @VincentFTS @emmby
Sorry for the delay on this. Did you come up with a generic solution? We are getting ready to [finally] push 4.49 and I'd like to see if we can add support for this to 4.49 or maybe 4.50 which should come out soon after.
I also think we should support this, so the users do not have to write the solution which is in your examples, introducing potential bugs if they are not careful.
@jiongxuan , did you send anything to @j256 ?
haha 5.0 already support!!