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

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

From source file:Main.java

public static File getLogPath(Context context) {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        File externalStorage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
        if (externalStorage == null)
            return null;
        return new File(externalStorage.getPath() + File.separatorChar + "logs");
    }/* w w w.  jav  a  2 s. c o m*/

    return null;
}

From source file:Main.java

public static File getStoragePath(Context context) {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        File externalStorage = context.getExternalFilesDir(null);
        if (externalStorage == null)
            return null;
        return new File(externalStorage.getPath() + File.separatorChar + "storage");
    }/*  www .ja va  2 s  . c o m*/

    return null;
}

From source file:Main.java

public static String getSDCardDataPath(Context context) {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        return Environment.getExternalStorageDirectory().getAbsolutePath();
    }//from   ww w  .  j a  v a2s .  c om
    return null;
}

From source file:Main.java

private static boolean isStorageReady() {
    String cardstatus = Environment.getExternalStorageState();
    if (cardstatus.equals(Environment.MEDIA_REMOVED) || cardstatus.equals(Environment.MEDIA_UNMOUNTED)
            || cardstatus.equals(Environment.MEDIA_UNMOUNTABLE)
            || cardstatus.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
        return false;
    } else {/*from w w  w .java 2  s . c o  m*/
        if (cardstatus.equals(Environment.MEDIA_MOUNTED)) {
            return true;
        } else {
            return false;
        }
    }
}

From source file:Main.java

/**
 * Checks if external storage is available for read and write. If not, show an error Toast.
 * //from  w  w  w.  ja v  a  2 s.  co m
 * @param context The Context in which the Toast will be shown.
 * @return True if external storage is writable. False otherwise.
 */
public static boolean isExternalStorageWritableErrorToast(Context context) {
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        return true;
    }
    // Toast.makeText(context, R.string.info_no_external_storage,
    // Toast.LENGTH_LONG).show();
    return false;
}

From source file:Main.java

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

From source file:Main.java

public static boolean isSdCardAvailable() {
    return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
}

From source file:Main.java

/**
 * Gets a bitmap from a path inside the TexturePoemApp-Folder
 * @param path path of the bitmap inside the TexturePoemApp-Folder
 * @return Decoded bitmap /*from w  ww  . j a  v  a2  s.  c  o  m*/
 */
public static Bitmap getBitmapFromPath(String path) {
    Bitmap b = null;
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        String galleryPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
                .toString();

        File f = new File(galleryPath + "/TexturePoemApp/" + path);
        if (f.exists()) {
            b = BitmapFactory.decodeFile(f.getAbsolutePath());
        }
    }

    return b;
}

From source file:Main.java

public static boolean externalStorageAvailable() {
    String externalStorageState = Environment.getExternalStorageState();
    return externalStorageState.equals(Environment.MEDIA_MOUNTED)
            && !externalStorageState.equals(Environment.MEDIA_MOUNTED_READ_ONLY);
}