diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-02-25 15:41:31 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-02-25 15:41:31 -0800 |
commit | dd4e9fd42e189614262fe5449ffc65ce6269d45c (patch) | |
tree | 48534ed825f39c0790eceb0c509712e49d0f12bb /src | |
parent | 0de2db96e3fef9db95ee74d2e63f602db6024d3f (diff) | |
download | dsub-dd4e9fd42e189614262fe5449ffc65ce6269d45c.tar.gz dsub-dd4e9fd42e189614262fe5449ffc65ce6269d45c.tar.bz2 dsub-dd4e9fd42e189614262fe5449ffc65ce6269d45c.zip |
#294 Auto reset cache location when it is no longer available
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 7444229b..7e047a94 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -434,9 +434,14 @@ public class SubsonicFragmentActivity extends SubsonicActivity { PreferenceManager.setDefaultValues(this, R.xml.settings, false);
SharedPreferences prefs = Util.getPreferences(this);
if (!prefs.contains(Constants.PREFERENCES_KEY_CACHE_LOCATION)) {
- SharedPreferences.Editor editor = prefs.edit();
- editor.putString(Constants.PREFERENCES_KEY_CACHE_LOCATION, FileUtil.getDefaultMusicDirectory(this).getPath());
- editor.commit();
+ resetCacheLocation(prefs);
+ } else {
+ String path = prefs.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null);
+ File cacheLocation = new File(path);
+ if(!FileUtil.ensureDirectoryExistsAndIsReadWritable(cacheLocation)) {
+ resetCacheLocation(prefs);
+ Util.info(this, R.string.common_warning, R.string.settings_cache_location_reset);
+ }
}
if (!prefs.contains(Constants.PREFERENCES_KEY_OFFLINE)) {
@@ -457,6 +462,12 @@ public class SubsonicFragmentActivity extends SubsonicActivity { }
}
+ private void resetCacheLocation(SharedPreferences prefs) {
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putString(Constants.PREFERENCES_KEY_CACHE_LOCATION, FileUtil.getDefaultMusicDirectory(this).getPath());
+ editor.commit();
+ }
+
private void createAccount() {
final Context context = this;
|