diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d7cf72c79..f3cf094b3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -174,5 +174,13 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
+
+
+
+
+
+
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt
index 818a47cb0..29d39b91a 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt
@@ -20,6 +20,9 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
var shouldStop = false
override fun doInBackground(vararg params: Void): ArrayList {
+ if (!context.hasWriteStoragePermission())
+ return ArrayList()
+
val media = ArrayList()
val showMedia = config.showMedia
val fileSorting = config.fileSorting
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/receivers/InstallReceiver.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/receivers/InstallReceiver.kt
new file mode 100644
index 000000000..fc3566bc0
--- /dev/null
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/receivers/InstallReceiver.kt
@@ -0,0 +1,16 @@
+package com.simplemobiletools.gallery.receivers
+
+import android.content.BroadcastReceiver
+import android.content.Context
+import android.content.Intent
+import com.google.gson.Gson
+import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask
+import com.simplemobiletools.gallery.extensions.config
+
+class InstallReceiver : BroadcastReceiver() {
+ override fun onReceive(context: Context, intent: Intent) {
+ GetDirectoriesAsynctask(context, false, false) {
+ context.config.directories = Gson().toJson(it)
+ }.execute()
+ }
+}