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 sdCardIsAvailable() {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        File sd = new File(Environment.getExternalStorageDirectory().getPath());
        return sd.canWrite();
    } else/*  w ww. j a v  a 2s .c  o  m*/
        return false;
}

From source file:Main.java

public static boolean isExitsSdcard() {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
        return true;
    else//  w w  w.j a  va2s  .  co m
        return false;
}

From source file:Main.java

public static boolean isSDCard() {
    return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
}

From source file:Main.java

public static boolean hasSDCardMounted() {
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state)) {
        return true;
    }/*from  w w w .  jav  a2  s  .  com*/
    try {
        if ((Build.MANUFACTURER).equalsIgnoreCase("HTC") && (Build.DEVICE).equalsIgnoreCase("inc")) {
            return true;
        }
    } catch (Exception pEx) {
        return false;
    }
    return false;
}

From source file:Main.java

/**
 * @return/*w w  w  . j  ava2  s. c om*/
 */
private static boolean hasSDCard() {
    return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
}

From source file:Main.java

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

From source file:Main.java

public static boolean hasExternalStorage() {
    Boolean externalStorage = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    return externalStorage;
}

From source file:Main.java

public static boolean isExternalStorageAvailable() {
    return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !isExternalStorageRemovable();
}

From source file:Main.java

/**
 * Returns the current state of the storage device that provides the given path.
 * @param state "getExternalStorageState()"
 *///from w  ww .j a  v a  2  s  . co  m
public static String getExternalStorageState(String state) {
    if (TextUtils.isEmpty(state)) {
        return UNKNOWN;
    }

    switch (state) {
    case Environment.MEDIA_BAD_REMOVAL://bad_removal
        return "MEDIA_BAD_REMOVAL";
    case Environment.MEDIA_CHECKING://checking
        return "MEDIA_CHECKING";
    case Environment.MEDIA_EJECTING://ejecting
        return "MEDIA_EJECTING";
    case Environment.MEDIA_MOUNTED://mounted
        return "MEDIA_MOUNTED";
    case Environment.MEDIA_MOUNTED_READ_ONLY://mounted_read_only
        return "MEDIA_MOUNTED_READ_ONLY";
    case Environment.MEDIA_NOFS://nofs
        return "MEDIA_NOFS";
    case Environment.MEDIA_REMOVED://removed
        return "MEDIA_REMOVED";
    case Environment.MEDIA_SHARED://shared
        return "MEDIA_SHARED";
    case Environment.MEDIA_UNKNOWN://unknown
        return "MEDIA_UNKNOWN";
    case Environment.MEDIA_UNMOUNTABLE://unmountable
        return "MEDIA_UNMOUNTABLE";
    case Environment.MEDIA_UNMOUNTED://unmounted
        return "MEDIA_UNMOUNTED";
    default:
        return UNKNOWN;
    }
}

From source file:Main.java

public static boolean hasExternalStorage() {
    Boolean externalStorage = Environment.getExternalStorageState()
            .equals(android.os.Environment.MEDIA_MOUNTED);
    return externalStorage;
}