[Android] preferences: do not hardcode root default to /sdcard, set it dynamically

Sébastien Toque git at videolan.org
Sun Oct 14 13:40:50 CEST 2012


vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sun Oct 14 13:40:24 2012 +0200| [055aa8dc1a3f9c5e631935b59a434960f758ef25] | committer: Sébastien Toque

preferences: do not hardcode root default to /sdcard, set it dynamically

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=055aa8dc1a3f9c5e631935b59a434960f758ef25
---

 vlc-android/res/xml/preferences.xml                |    2 --
 vlc-android/src/org/videolan/vlc/MediaLibrary.java |    4 ++++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
index 4d35c7d..af39c9a 100644
--- a/vlc-android/res/xml/preferences.xml
+++ b/vlc-android/res/xml/preferences.xml
@@ -3,13 +3,11 @@
     <PreferenceCategory android:title="@string/mediafiles">
         <EditTextPreference
             android:key="directories_root"
-            android:defaultValue="/sdcard"
             android:title="@string/filebrowser_root">
         </EditTextPreference>
         <PreferenceScreen
             android:key="directories"
             android:title="@string/directories"
-            android:defaultValue="/sdcard"
             android:summary="@string/filebrowser_title">
         </PreferenceScreen>
     </PreferenceCategory>
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index b6cf3f8..7a6e3fc 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -36,6 +36,7 @@ import org.videolan.vlc.gui.video.VideoGridFragment;
 
 import android.content.Context;
 import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
 import android.os.Environment;
 import android.os.Handler;
 import android.os.Message;
@@ -201,6 +202,9 @@ public class MediaLibrary {
             // use the external storage as our default root directory (most often /mnt/sdcard)
             if (root == null) {
                 root = Environment.getExternalStorageDirectory().getAbsolutePath();
+                Editor edit = pref.edit();
+                edit.putString("directories_root", root);
+                edit.commit();
             } else {
                 root = new File(root).getAbsolutePath();
             }



More information about the Android mailing list