文件夹不为空但显示空

时间:2016-08-09 12:57:47

标签: android

我想检查该文件夹是否为空。

File dir = new File(Environment.getExternalStorageDirectory() + "/media_files");
if (dir.exists() && dir.isDirectory()) {
    File[] contents = dir.listFiles();
    if (contents == null) {
        //Always run this code              
        storeListing();
    } else if (contents.length == 0) {
        storeListing();
    } else {
        selectStore();
    }
} else {
    storeListing();
}

拥有权限

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

内容始终显示为空。但我在 media_files 文件夹中有视频文件。 这是logcat

  

08-10 12:49:55.265 24523-24523 / com.css.css I / art:延迟启用-Xcheck:jni   08-10 12:49:55.438 24523-24523 / com.css.css W / art:在Android 4.1之前,方法android.graphics.PorterDuffColorFilter   android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter,android.content.res.ColorStateList,android.graphics.PorterDuff $ Mode)会错误地覆盖android.graphics.drawable中的package-private方法。可绘制   08-10 12:49:55.493 24523-24523 / com.abc.css D / URL =:http:// ......   08-10 12:49:55.522 24523-24579 / com.abc.css D / OpenGLRenderer:使用EGL_SWAP_BEHAVIOR_PRESERVED:true   08-10 12:49:55.558 24523-24579 / com.abc.css I / Adreno-EGL :: QUALCOMM Build:10/21 / 15,369a2ea,I96aee987eb   08-10 12:49:55.559 24523-24579 / com.abc.css I / OpenGLRenderer:初始化的EGL,版本1.4   08-10 12:49:57.531 24523-24523 / com.abc.css D / Response ==&gt;:{“store”:{“id”:1,“name”:“tib”,“template_id”:3 , “模板”:{ “gfram”:[{....   08-10 12:51:05.891 24523-24529 / com.abc.css I / art:调试器不再有效

您的建议将不胜感激

0 个答案:

没有答案