[Android] [PATCH 8/8] extract database access to AsyncTask

Yu Lin yu.lin.86 at gmail.com
Tue Mar 4 23:33:46 CET 2014


---
 .../src/org/videolan/vlc/VLCApplication.java       |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index 00e7ad9..5dda4da 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -28,6 +28,7 @@ import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.res.Configuration;
 import android.content.res.Resources;
+import android.os.AsyncTask;
 import android.preference.PreferenceManager;
 import android.util.Log;
 
@@ -74,10 +75,15 @@ public class VLCApplication extends Application {
 
         instance = this;
 
-        // Initialize the database soon enough to avoid any race condition and crash
-        MediaDatabase.getInstance(this);
-        // Prepare cache folder constants
-        AudioUtil.prepareCacheFolder(this);
+        new AsyncTask<Void, Void, Void>() {
+            protected Void doInBackground(Void... args) {
+                // Initialize the database soon enough to avoid any race condition and crash
+                MediaDatabase.getInstance(VLCApplication.this);
+                // Prepare cache folder constants
+                AudioUtil.prepareCacheFolder(VLCApplication.this);
+                return null;
+            }
+        }.execute();
     }
 
     /**
-- 
1.7.4.4



More information about the Android mailing list