Commit 4aae9ab4 authored by Geoffrey Métais's avatar Geoffrey Métais

Catch NPE thrown by framework in getExternalCacheDir()

parent d49ba4b8
......@@ -119,10 +119,14 @@ public class AudioUtil {
@SuppressLint("NewApi")
public static void prepareCacheFolder(Context context) {
if (LibVlcUtil.isFroyoOrLater() && AndroidDevices.hasExternalStorage() && context.getExternalCacheDir() != null)
CACHE_DIR = context.getExternalCacheDir().getPath();
else
try {
if (LibVlcUtil.isFroyoOrLater() && AndroidDevices.hasExternalStorage() && context.getExternalCacheDir() != null)
CACHE_DIR = context.getExternalCacheDir().getPath();
else
CACHE_DIR = Environment.getExternalStorageDirectory().getPath() + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache";
} catch (Exception e) { // catch NPE thrown by getExternalCacheDir()
CACHE_DIR = Environment.getExternalStorageDirectory().getPath() + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache";
}
ART_DIR = CACHE_DIR + "/art/";
COVER_DIR = CACHE_DIR + "/covers/";
PLAYLIST_DIR = CACHE_DIR + "/playlists/";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment