[Android] Move database in app files directory
Geoffrey Métais
git at videolan.org
Mon Jul 17 10:01:09 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jul 17 09:41:36 2017 +0200| [3e9fbe0dd7d50b9680d3038ff6e7493e1053a21a] | committer: Geoffrey Métais
Move database in app files directory
Application cache could be erased
> https://code.videolan.org/videolan/vlc-android/commit/3e9fbe0dd7d50b9680d3038ff6e7493e1053a21a
---
medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 5 ++---
vlc-android/src/org/videolan/vlc/MediaParsingService.java | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index c840c6619..2af0a71b6 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -76,11 +76,10 @@ public class Medialibrary {
public boolean init(Context context) {
if (context == null)
return false;
- File cacheDir = context.getCacheDir();
File extFilesDir = context.getExternalFilesDir(null);
- if (extFilesDir == null || !cacheDir.exists() || !extFilesDir.exists())
+ if (extFilesDir == null || !extFilesDir.exists())
return false;
- mIsInitiated = nativeInit(cacheDir+ VLC_MEDIA_DB_NAME, extFilesDir.getAbsolutePath()+ THUMBS_FOLDER_NAME);
+ mIsInitiated = nativeInit(extFilesDir.getAbsolutePath()+ VLC_MEDIA_DB_NAME, extFilesDir.getAbsolutePath()+ 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 465f90ad0..a1d0c5409 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.getCacheDir()+Medialibrary.VLC_MEDIA_DB_NAME).exists());
+ boolean shouldInit = !(new File(MediaParsingService.this.getExternalFilesDir(null)+Medialibrary.VLC_MEDIA_DB_NAME).exists());
if (mMedialibrary.init(VLCApplication.getAppContext())) {
List<String> devices = new ArrayList<>();
devices.add(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);
More information about the Android
mailing list