package org.stepic.droid.util;

import android.content.Context;
import android.support.v4.content.ContextCompat;

import org.jetbrains.annotations.Nullable;

import java.io.File;

public class StorageUtil {
    public enum SDState {
        sdcardMounted,
        sdCardNotMounted,
        sdCardNotAvailableOnDevice,
        accessToStorageRestricted
    }

    @Nullable
    public static SDState getSDState(@Nullable Context context) {
        if (context == null) return null;

        File[] files = ContextCompat.getExternalFilesDirs(context, null);
        if (files == null || files.length <= 0) {
            return SDState.accessToStorageRestricted;
        }

        if (files.length == 1) {
            return SDState.sdCardNotAvailableOnDevice;
        } else {
            //files.length >= 2
            if (files[1] == null) {
                return SDState.sdCardNotMounted;
            } else {
                return SDState.sdcardMounted;
            }
        }
    }
}

@@ -149,16 +149,62 @@
 ullable;
+%0Aimport org.stepic.droid.base.MainApplication;
 %0A%0Aimport
@@ -1028,11 +1028,151 @@
  %7D%0A    %7D
+%0A%0A    public static File%5B%5D getRawAppDirs() %7B%0A        return ContextCompat.getExternalFilesDirs(MainApplication.getAppContext(), null);%0A    %7D
 %0A%7D%0A

add getting storage util