From fabb07bb28b996b691d23ee38fd561c4c6e87e49 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sun, 4 Aug 2019 17:27:56 +0200 Subject: [PATCH] fix import settings not working --- .../org/schabi/newpipe/database/Migrations.java | 13 +++++++++++++ .../newpipe/settings/ContentSettingsFragment.java | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/Migrations.java b/app/src/main/java/org/schabi/newpipe/database/Migrations.java index 239fc02bb..9d24dbb08 100644 --- a/app/src/main/java/org/schabi/newpipe/database/Migrations.java +++ b/app/src/main/java/org/schabi/newpipe/database/Migrations.java @@ -3,15 +3,24 @@ package org.schabi.newpipe.database; import android.arch.persistence.db.SupportSQLiteDatabase; import android.arch.persistence.room.migration.Migration; import android.support.annotation.NonNull; +import android.util.Log; + +import org.schabi.newpipe.BuildConfig; public class Migrations { public static final int DB_VER_11_0 = 1; public static final int DB_VER_12_0 = 2; + public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release"); + private static final String TAG = Migrations.class.getName(); + public static final Migration MIGRATION_11_12 = new Migration(DB_VER_11_0, DB_VER_12_0) { @Override public void migrate(@NonNull SupportSQLiteDatabase database) { + if(DEBUG) { + Log.d(TAG, "Start migrating database"); + } /* * Unfortunately these queries must be hardcoded due to the possibility of * schema and names changing at a later date, thus invalidating the older migration @@ -56,6 +65,10 @@ public class Migrations { "ORDER BY creation_date DESC"); database.execSQL("DROP TABLE IF EXISTS watch_history"); + + if(DEBUG) { + Log.d(TAG, "Stop migrating database"); + } } }; } diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index 82604f7da..25b443b1b 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -274,7 +274,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { else if (v instanceof String) prefEdit.putString(key, ((String) v)); } - prefEdit.apply(); + prefEdit.commit(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) {