From e80b754605d7734346da688d9549ee06c85b4ebf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 30 Oct 2016 02:00:49 +0200 Subject: [PATCH] List files only once, also avoids a potential race condition. --- src/com/hughes/android/dictionary/DictionaryApplication.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/hughes/android/dictionary/DictionaryApplication.java b/src/com/hughes/android/dictionary/DictionaryApplication.java index 5d1ca0e..1e46f4b 100644 --- a/src/com/hughes/android/dictionary/DictionaryApplication.java +++ b/src/com/hughes/android/dictionary/DictionaryApplication.java @@ -406,7 +406,8 @@ public class DictionaryApplication extends Application { final File defaultDictDir = new File(Environment.getExternalStorageDirectory(), "quickDic"); String dir = defaultDictDir.getAbsolutePath(); File dictDir = new File(dir); - if (dictDir.isDirectory() && dictDir.list() != null && dictDir.list().length > 0) { + String[] fileList = dictDir.isDirectory() ? dictDir.list() : null; + if (fileList != null && fileList.length > 0) { return dir; } File efd = null; -- 2.43.0