Example usage for android.os Environment MEDIA_MOUNTED

List of usage examples for android.os Environment MEDIA_MOUNTED

Introduction

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

Prototype

String MEDIA_MOUNTED

To view the source code for android.os Environment MEDIA_MOUNTED.

Click Source Link

Document

Storage state if the media is present and mounted at its mount point with read/write access.

Usage

From source file:Main.java

public static boolean avaiableSDCard() {

    String status = Environment.getExternalStorageState();

    if (status.equals(Environment.MEDIA_MOUNTED)) {
        return true;
    } else {//from   w  w  w  .j a v  a  2  s .c o  m
        return false;
    }
}

From source file:Main.java

public static boolean isSDCardExist() {

    String state = Environment.getExternalStorageState();

    if (state.equals(Environment.MEDIA_MOUNTED))

        return true;

    else//from ww  w  .  j  a  va  2s  . com

        return false;
}

From source file:Main.java

public static File getDiskDir(String uniqueName) {
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        File storageDirectory = Environment.getExternalStorageDirectory();
        if (storageDirectory != null) {
            File file = new File(storageDirectory + File.separator + uniqueName);
            if (!file.exists() && !file.isDirectory()) {
                file.mkdir();/*from  ww w .j  a  v a 2  s .  c  o  m*/
            }
            return file;
        }
    }
    return null;
}

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 getSDCardStatus() {
    return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
}

From source file:Main.java

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

From source file:Main.java

public static boolean checkSDCardStatus() {
    String sdcardStatus = Environment.getExternalStorageState();
    return sdcardStatus.equals(android.os.Environment.MEDIA_MOUNTED);
}

From source file:Main.java

public static String getDiskCacheDir(Context context) {

    String cachePath = null;/*from   w  ww .j  av  a 2 s.  co m*/
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            && !Environment.isExternalStorageRemovable() && context.getExternalCacheDir() != null) {
        cachePath = context.getExternalCacheDir().getPath();
    } else {
        cachePath = context.getCacheDir().getPath();
    }

    return cachePath;
}

From source file:Main.java

public static File getDataRoot() {
    try {/*ww w .  j a v a  2  s .  co  m*/
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
                || (Environment.getExternalStorageDirectory().exists()
                        && Environment.getExternalStorageDirectory().canWrite())) {
            return Environment.getExternalStorageDirectory();
        } else {
            return Environment.getDataDirectory();
        }
    } catch (Exception e) {
        return null;
    }
}

From source file:Main.java

public static boolean isSDcardState() {

    String sdcardState = Environment.getExternalStorageState();

    if (sdcardState.equals(Environment.MEDIA_MOUNTED)) {
        return true;
    }/*ww w .  j  a  va2  s. com*/

    return false;
}