From 30613b7064d3988e181b6e601269dc1cfd9e827a Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Tue, 15 Dec 2020 08:02:25 +0530 Subject: [PATCH] Use ContextCompat.getDataDir(). --- .../settings/ContentSettingsFragment.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 b0425ebfa..1ef52cd82 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -11,6 +11,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import androidx.preference.Preference; import androidx.preference.PreferenceManager; @@ -120,15 +121,14 @@ public class ContentSettingsFragment extends BasePreferenceFragment { @Override public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { + final File homeDir = ContextCompat.getDataDir(requireContext()); + databasesDir = new File(homeDir, "/databases"); + newpipeDb = new File(homeDir, "/databases/newpipe.db"); + newpipeDbJournal = new File(homeDir, "/databases/newpipe.db-journal"); + newpipeDbShm = new File(homeDir, "/databases/newpipe.db-shm"); + newpipeDbWal = new File(homeDir, "/databases/newpipe.db-wal"); - final String homeDir = getActivity().getApplicationInfo().dataDir; - databasesDir = new File(homeDir + "/databases"); - newpipeDb = new File(homeDir + "/databases/newpipe.db"); - newpipeDbJournal = new File(homeDir + "/databases/newpipe.db-journal"); - newpipeDbShm = new File(homeDir + "/databases/newpipe.db-shm"); - newpipeDbWal = new File(homeDir + "/databases/newpipe.db-wal"); - - newpipeSettings = new File(homeDir + "/databases/newpipe.settings"); + newpipeSettings = new File(homeDir, "/databases/newpipe.settings"); newpipeSettings.delete(); addPreferencesFromResource(R.xml.content_settings);