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 String getSdCacheDir(Context context) {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        java.io.File fExternalStorageDirectory = Environment.getExternalStorageDirectory();
        java.io.File autonaviDir = new java.io.File(fExternalStorageDirectory, "amapsdk");
        boolean result = false;
        if (!autonaviDir.exists()) {
            result = autonaviDir.mkdir();
        }/*from ww  w  . ja  va2s.  c  o m*/
        java.io.File minimapDir = new java.io.File(autonaviDir, "offlineMap");
        if (!minimapDir.exists()) {
            result = minimapDir.mkdir();
        }
        return minimapDir.toString() + "/";
    } else {
        return "";
    }
}

From source file:Main.java

public static String getSDPath() {
    File sdDir = null;/*from w  w  w  .  j av a  2 s. com*/
    boolean sdCardExist = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    if (sdCardExist) {
        sdDir = Environment.getExternalStorageDirectory(); // get root path
        return sdDir.toString();
    }
    return null;
}

From source file:Main.java

public static String getSDPath() {
    File sdDir = null;/* w w  w  .  j ava  2  s  .  c  o  m*/
    boolean sdCardExist = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    if (sdCardExist) {
        sdDir = Environment.getExternalStorageDirectory();
    }
    String dir = sdDir.toString();
    return dir;
}

From source file:Main.java

public static String getRootByApi() {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        File file = Environment.getExternalStorageDirectory();
        if (file == null)
            return null;
        String path = file.getAbsolutePath();
        if (isValidRoot(path))
            return path;
    }//from   ww  w . j a  va  2 s . c  o  m
    return null;
}

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 hasSDCard() {
    String status = Environment.getExternalStorageState();

    return status.equals(Environment.MEDIA_MOUNTED);
}

From source file:Main.java

public static String getSDPath() {
    File SDdir = null;/* www  .  j ava  2s.co  m*/
    boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
    if (sdCardExist) {
        SDdir = Environment.getExternalStorageDirectory();
    }
    if (SDdir != null) {
        return SDdir.toString();
    } else {
        return null;
    }
}

From source file:Main.java

public static String getCachePath(Context context, String uniqueName) {
    String cachePath;// ww w  .  ja  v  a2 s.co  m
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        cachePath = context.getExternalCacheDir().getPath();
    } else {
        cachePath = context.getCacheDir().getPath();
    }
    return cachePath + File.separator + uniqueName;
}

From source file:Main.java

public static File getTempImage() throws IOException {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        File tempFile = new File(Environment.getExternalStorageDirectory(), "temp.jpg");
        tempFile.createNewFile();/* w  w  w  . ja v a2  s  .  com*/
        return tempFile;
    }
    throw new IOException("cannot find any sdcard.");
}

From source file:Main.java

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