I am using green dao and I came to a point in wich I am supporting multilanguage and I would like to use diffrent databases for each language.
Till now I have been creating my database by using green dao. Now I would like to have multiple databases inside assets and just open the one I need and manipulate it with green dao.
How can I do that?
This is my method for creating the database:
public static DaoMaster getDaoMaster(Context context)
{
if(daoMaster == null)
{
OpenHelper helper = new OpenHelper(context, "dbSlo", null) {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
};
//DevOpenHelper helper = new DevOpenHelper(context, "tronpos-db", null);
db = helper.getWritableDatabase();
daoMaster = new DaoMaster(db);
}
return daoMaster;
}
Now instead of creating one I want to open an existing (dbSlo that I have in assets) and then manipulate with it normaly.
copy before open. Just in the onCreateof your app class call something like the method described in here: Copy Database from assets folder in unrooted device
That way you check for preexisting or create the new one by copiying from the assets.