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

public static boolean isExternalStorageWritable() {
    String state = Environment.getExternalStorageState();
    return Environment.MEDIA_MOUNTED.equals(state);
}

From source file:Main.java

public static boolean sdCardMounted() {
    final String state = Environment.getExternalStorageState();
    if (state.equals(Environment.MEDIA_MOUNTED) && !state.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
        return true;
    }//ww  w  .j  a v  a 2  s  .c o m
    return false;
}

From source file:Main.java

public static boolean sdCardIsAvailable() {
    String status = Environment.getExternalStorageState();
    if (!status.equals(Environment.MEDIA_MOUNTED)) {
        return false;
    } else {/*ww w  . j a  v a2 s .  c  o  m*/
        return true;
    }
}

From source file:Main.java

public static boolean isSDCardAvailable() {
    String status = Environment.getExternalStorageState();
    if (!status.equals(Environment.MEDIA_MOUNTED)) {
        return false;
    } else {//from www .java  2 s. com
        return true;
    }
}

From source file:Main.java

public static boolean checkSDcard() {
    boolean flag;
    if (Environment.getExternalStorageState().equals("mounted"))
        flag = true;//from   w  w  w  .  j  a va 2 s  .  c  o m
    else
        flag = false;
    return flag;
}

From source file:Main.java

public static boolean avaiableSDCard() {

    String status = Environment.getExternalStorageState();

    if (status.equals(Environment.MEDIA_MOUNTED)) {
        return true;
    } else {//from  ww w  . jav  a 2  s. c  om
        return false;
    }
}

From source file:Main.java

public static boolean SDExist() {
    boolean ret = false;
    if (Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
        ret = true;/*from   ww w . j  ava  2  s  . c  o  m*/
    }
    return ret;
}

From source file:Main.java

public static boolean isExternalStorageReadable() {
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        return true;
    }/*from  w ww  . j a v  a2 s  . c o  m*/
    return false;
}

From source file:Main.java

public static boolean isExternalStorageReadable() {
    final String state = Environment.getExternalStorageState();
    return state.equals(Environment.MEDIA_MOUNTED) || state.equals(Environment.MEDIA_MOUNTED_READ_ONLY);
}

From source file:Main.java

public static boolean IsCanUseSdCard() {
    try {//w w  w  .jav  a2s. co m
        return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}