[Android] Move medialibrary database in app data directory

Geoffrey Métais git at videolan.org
Mon Jul 17 10:50:29 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jul 17 10:49:12 2017 +0200| [3a02a917cc85230da4e13590b7f2208459fe6694] | committer: Geoffrey Métais

Move medialibrary database in app data directory

> https://code.videolan.org/videolan/vlc-android/commit/3a02a917cc85230da4e13590b7f2208459fe6694
---

 medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 3 ++-
 vlc-android/src/org/videolan/vlc/MediaParsingService.java    | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 2af0a71b6..99f4da170 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -77,9 +77,10 @@ public class Medialibrary {
         if (context == null)
             return false;
         File extFilesDir = context.getExternalFilesDir(null);
+        File dbDirectory = context.getDir("db", Context.MODE_PRIVATE);
         if (extFilesDir == null || !extFilesDir.exists())
             return false;
-        mIsInitiated = nativeInit(extFilesDir.getAbsolutePath()+ VLC_MEDIA_DB_NAME, extFilesDir.getAbsolutePath()+ THUMBS_FOLDER_NAME);
+        mIsInitiated = nativeInit(dbDirectory+ VLC_MEDIA_DB_NAME, extFilesDir+ THUMBS_FOLDER_NAME);
         return mIsInitiated;
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index 7b49f8b7e..993a39958 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -216,7 +216,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
             mCallsExecutor.execute(new Runnable() {
                 @Override
                 public void run() {
-                    boolean shouldInit = !(new File(MediaParsingService.this.getExternalFilesDir(null)+Medialibrary.VLC_MEDIA_DB_NAME).exists());
+                    boolean shouldInit = !(new File(MediaParsingService.this.getDir("db", Context.MODE_PRIVATE)+Medialibrary.VLC_MEDIA_DB_NAME).exists());
                     if (mMedialibrary.init(getApplicationContext())) {
                         List<String> devices = new ArrayList<>();
                         devices.add(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);



More information about the Android mailing list