@Phil. Yes, it works for me. However, I donβt remember what the real problem was, so Iβll just write a simplified sequence of steps that I found in my code regarding copying from firstDB to secondDB . I perform the following operations in SQLiteOpenHelper for firstDB .
public class firstDBHandler extends SQLiteOpenHelper { SQLiteDatabase firstDB;
then you just call:
FirstDBHandler firstDBHandler = new FirstDBHandler(getBaseContext(), FIRST_DB_NAME, FIRST_DB_VERSION); firstDBHandler.getReadableDatabase(); firstDBHandler.copyFromFirstToSecond(SECOND_DB_NAME, SECOND_DB_VERSION);
Of course, there are onCreate methods that are missing for both SQLiteOpenHandler and the application, which is done there.
I hope the answer does not contain errors. I did not test it myself, I just extracted a simplified version from my more complex code. If he has several upvotes, I mark this as an answer.
source share