Thank you,
Paolo
> Is, as your opinion, my trick to manage multi-db correct?
...
Sorry for the delay on this. This has been asked before but I've never taken a hard look at it. I've added yet another HelloAndroid application but this time called HelloAndroidTwoDbs. Here's the URL for the source:
www: http://ormlite.svn.sourceforge.net/viewvc/ormlite/examples/android/HelloAndroidTwoDbs/
svn: https://ormlite.svn.sourceforge.net/svnroot/ormlite/examples/android/HelloAndroidTwoDbs/
This piggybacks on the HelloAndroidNoBase project I added recently. It does not use the OrmLiteBaseActivity or other base classes at all and does not even use the OpenHelperManager manager. It creates two separate helpers using static methods on each of them. Each helper then manages each of the databases.
To use the helpers, you must call DatabaseHelper.getHelper(context). For every call to getHelper() from the Activity or Service as they start up, there should be a single corresponding call to close() when it is shutting down. If there are 3 calls to getHelper() in the application then there should be 3 calls to close(). The last call to close is when the helper and any associated database connections are shut down.
I'd be curious if anyone else is doing multiple databases and how they've handled it.
gray
I've a question....I have a list of db and when I select one of this I
want to switch ...
This is my solution...
I use an OrmLiteBaseActivityGroup, where all the childrens are Activity.
In each activity to get the helper I use the getHelper of the parent (
OrmLiteBaseActivityGroup instance )
When I want to switch beetween db, I close the helper of the
OrmLiteBaseActivityGroup instance and I reopen this passing the name
of the new Db on the constructor of the database helper.
Something like this:
public MyDatabaseHelper(Context context) {
super(context, getDbName(context), null, getDbVersion(context));
}
public static String getDbName(Context context)
{
I get the name in the Shared Preferences...where previous I saved the name
....
}
Is this a good or a bad idea?!
I hope that you will understand my bad english !!! Sorry :D
Thanks !
The name of the new db
So... If I use an OrmLiteBaseActivityGroup and to call the helper I
use only the getHelper() of the OrmLiteBaseActivityGroup instance, can
I
If I use an Orm
2011/10/21 Gray Watson <256...@gmail.com>:
Each db contains a configuration of the app
2011/10/21 David Fire <ddf...@gmail.com>:
> public MyDatabaseHelper(Context context) {
> super(context, getDbName(context), null, getDbVersion(context));
> }
>
> Is this a good or a bad idea?!
> I hope that you will understand my bad english !!! Sorry :D
Sorry Paolo but I just don't know if it is good or not. Seems like a complicated mechanism for sure but that doesn't necessarily mean that it is bad.
Best of luck,
gray
I'm sorry, but anyone answered my question:
Which is, as your opinion, the best way to handle many db ( not fixed
number, whit a unique DatabaseHandler ) using an app whit many
activities ?!?
2011/10/21 Gray Watson <256...@gmail.com>:
I choose this way cause it's the unique solution to obtaing my goal
Thanks
2011/10/21 David Fire <ddf...@gmail.com>:
Filipe
2011/10/21 Filipe Leandro <screami...@gmail.com>: