Example usage for android.os Environment getExternalStorageState

List of usage examples for android.os Environment getExternalStorageState

Introduction

In this page you can find the example usage for android.os Environment getExternalStorageState.

Prototype

public static String getExternalStorageState() 

Source Link

Document

Returns the current state of the primary shared/external storage media.

Usage

From source file:Main.java

private static boolean existSDCard() {
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        return true;
    } else/*w ww .  ja v  a 2  s . c om*/
        return false;
}

From source file:Main.java

private static boolean isExternalStorageReadable() {
    final String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        return true;
    }//from w w w.java  2 s.c o  m
    return false;
}

From source file:Main.java

private static boolean isExternalStorageWritable() {
    final String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state)) {
        return true;
    }//from  w  ww. ja v  a  2 s. c o  m
    return false;
}

From source file:Main.java

public static boolean isSDCardEnable() {
    return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
}

From source file:Main.java

public static long getSDTotalSize() {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        return getTotalSize(Environment.getExternalStorageDirectory().toString());
    }/* w ww.  j  a  v a  2s .c  o  m*/

    return 0;
}

From source file:Main.java

public static void deleteFile(File file) {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        if (file.exists()) {
            if (file.isFile()) {
                file.delete();//from w  w w  .  j a  v a  2  s  .co m
            }

            file.delete();
        }
    }
}

From source file:Main.java

public static String getInternalStorage() {
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))
        return Environment.getExternalStorageDirectory().getAbsolutePath();
    return "";
}

From source file:Main.java

public static File getStoragePath() {
    String state = Environment.getExternalStorageState();

    if (Environment.MEDIA_MOUNTED.equals(state)) {
        return Environment.getExternalStorageDirectory();
    } else {//from   w  w  w  .  ja va2s . c  o  m
        return null;
    }
}

From source file:Main.java

public static boolean isSDCardExist() {
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        return true;
    }//from  w w  w . jav a  2 s. c  o m
    return false;
}

From source file:Main.java

public static boolean isExternalStorageAvailable() {
    String extStorageState = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(extStorageState)) {
        return true;
    }//from www .j av a 2s . co  m
    return false;
}