Skip to content

Commit

Permalink
Add old db migration
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita36078 committed Sep 22, 2020
1 parent 01b5950 commit 89b3e16
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ private static boolean moveDefaultToProfiles() {
return list != null && list.length > 0;
}

private static void moveDatabase(Context context) {
File srcDb = new File(context.getApplicationInfo().dataDir, "databases/apps-database.db");
File dstDb = new File(Config.getEmulatorDir(), "J2ME-apps.db");
if (srcDb.exists()) {
try {
File dstDbShm = new File(dstDb + "-shm");
File dstDbWal = new File(dstDb + "-wal");
FileUtils.copyFileUsingChannel(srcDb, dstDb);
FileUtils.copyFileUsingChannel(new File(srcDb + "-shm"), dstDbShm);
FileUtils.copyFileUsingChannel(new File(srcDb + "-wal"), dstDbWal);
} catch (IOException e) {
e.printStackTrace();
}
}
}

private static int readVersion(File file) throws IOException {
int version;
try (FileInputStream in = new FileInputStream(file)) {
Expand Down Expand Up @@ -142,6 +158,7 @@ public static void check(Context context) {
.edit().putString(Config.PREF_DEFAULT_PROFILE, "default")
.apply();
}
moveDatabase(context);
}
try {
writeVersion(file);
Expand Down

0 comments on commit 89b3e16

Please sign in to comment.