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 isExternalSDStorage() {
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state) && Environment.isExternalStorageRemovable()) {
        return true;
    }/*from w  w w .  j  a v a  2s. c om*/
    return false;
}

From source file:Main.java

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

From source file:Main.java

public static boolean IsCanUseSdCard() {
    try {//from  w ww.j  a v  a2 s . co m
        return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}

From source file:Main.java

public static boolean isSDCardAvaiable() {
    try {//www  .  j a  v a  2  s .  c  o  m
        return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    } catch (Exception e) {
    }
    return false;
}

From source file:Main.java

private 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 String dstPath(Context context) {
    String cachePath;//from  w  w  w. j av a 2  s . c  o m
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        cachePath = context.getExternalCacheDir().getPath();
    } else {
        cachePath = context.getCacheDir().getPath();
    }
    return cachePath;
}

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 hasSdcard() {
    String status = Environment.getExternalStorageState();
    if (status.equals(Environment.MEDIA_MOUNTED))
        return true;
    else/*  w  w w.  j  a  v a2 s  .  c o  m*/
        return false;
}

From source file:Main.java

public static File getDiskCacheDir(Context context) {
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        return context.getExternalCacheDir();
    } else {/* w w  w . j av  a  2  s. c  o  m*/
        return context.getCacheDir();
    }
}

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;
    }/* w  w  w .  j  a v a  2  s  .c om*/
    return false;
}