0

I want to check that folder is empty or not.

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();
}

having permissions

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

Contents always shows empty. But I have video files in media_files folder. here is logcat

08-10 12:49:55.265 24523-24523/com.css.css I/art: Late-enabling -Xcheck:jni 08-10 12:49:55.438 24523-24523/com.css.css W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 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: Use 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: Initialized EGL, version 1.4 08-10 12:49:57.531 24523-24523/com.abc.css D/Response ==>: {"store":{"id":1,"name":"tib","template_id":3,"template":{"gfram":[{.... 08-10 12:51:05.891 24523-24529/com.abc.css I/art: Debugger is no longer active

Your suggestion will be appreciated

M.ArslanKhan
  • 3,640
  • 8
  • 34
  • 56
  • 1
    have you checked for permission? – Gyanendra Mani Aug 09 '16 at 12:58
  • @Sohail Zahid and Gyanendra Mani device on android 6.0.1. Android studio targetSdkVersion 23 compileSdkVersion 23 buildToolsVersion "23.0.2" – M.ArslanKhan Aug 09 '16 at 13:18
  • For Android 6.0 you have to get runtime permission from user [**see my earlior answer.**](http://stackoverflow.com/questions/38141523/directory-creation-not-working-in-marshmallow-android/38141778#38141778) – Sohail Zahid Aug 09 '16 at 13:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/120585/discussion-between-tarikhelian-and-sohail-zahid). – M.ArslanKhan Aug 10 '16 at 09:56

0 Answers0