> I'm developing with Android and I need to pass the DB name to the
> Helper class, not as the examples which defines the name in a static
> private member on the helper class.
>
> In particular, I need to get the Db name from the Shared Preferences
> of the app, but the OrmLiteSqliteOpenHelper can't acces to the Shared
> Preferences, and for this I need to pass in some way this string.
Is this really true Paolo? The open helper has access to the Context and you can do a getSharedPreferences(...):
In your DatabaseHelper class, the constructor gets passed the Context and you should be able to create a static method to extract the database name from the Context and pass it up to the OrmLiteSqliteOpenHelper constructor. Something like:
public DatabaseHelper(Context context) {
super(context, extractDatabaseName(context), null, DATABASE_VERSION);
}
private static String extractDatabaseName(Context context) {
SharedPreferences prefs = context.getSharedPreferences(..., ...);
return prefs.getString(..., ...);
}
Won't that work? Anyone else want to comment?
gray