From c9f20cecaec283c02ffd47ec69f8381bc833c89d Mon Sep 17 00:00:00 2001 From: xdavidwu Date: Tue, 11 Jun 2019 14:16:39 +0800 Subject: [PATCH] notify root change when config changes --- src/main/java/org/safsftp/MainActivity.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/safsftp/MainActivity.java b/src/main/java/org/safsftp/MainActivity.java index b934b16..10d1395 100644 --- a/src/main/java/org/safsftp/MainActivity.java +++ b/src/main/java/org/safsftp/MainActivity.java @@ -2,14 +2,20 @@ package org.safsftp; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; +import android.net.Uri; import android.preference.EditTextPreference; import android.preference.PreferenceActivity; +import android.provider.DocumentsContract; import android.os.Bundle; public class MainActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener { - private EditTextPreference hostText, portText, usernameText, passwdText; + + private void notifyRootChanges(){ + Uri uri=DocumentsContract.buildRootsUri("org.safsftp"); + getContentResolver().notifyChange(uri,null); + } @Override public void onCreate(Bundle savedInstanceState) { @@ -28,6 +34,7 @@ public class MainActivity extends PreferenceActivity @Override public void onSharedPreferenceChanged(SharedPreferences settings, String key) { + notifyRootChanges(); switch(key){ case "host": if (settings.getString("host", "").equals("")) -- 2.45.2