From a81f6c3ac44050b86c8cd05d930489153b5127f8 Mon Sep 17 00:00:00 2001 From: inorichi Date: Wed, 10 Feb 2016 15:41:59 +0100 Subject: [PATCH] Trying to give write permissions on SD card --- .../tachiyomi/ui/setting/SettingsDownloadsFragment.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadsFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadsFragment.java index a7852bfb24..6e1118b0a9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadsFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadsFragment.java @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.setting; import android.app.Activity; import android.content.Intent; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.preference.Preference; import android.support.v7.widget.RecyclerView; @@ -61,6 +62,13 @@ public class SettingsDownloadsFragment extends SettingsNestedFragment { if (requestCode == DOWNLOAD_DIR_CODE && resultCode == Activity.RESULT_OK) { Uri uri = data.getData(); preferences.setDownloadsDirectory(uri.getPath()); + + // Persist access permissions. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + getActivity().getContentResolver().takePersistableUriPermission(uri, + Intent.FLAG_GRANT_READ_URI_PERMISSION | + Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + } } }