List of usage examples for android.os Environment MEDIA_MOUNTED_READ_ONLY
String MEDIA_MOUNTED_READ_ONLY
To view the source code for android.os Environment MEDIA_MOUNTED_READ_ONLY.
Click Source Link
From source file:Main.java
public static boolean hasStorage(boolean requireWriteAccess) { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { if (requireWriteAccess) { boolean writable = checkFsWritable(); return writable; } else {// ww w.j av a 2 s . co m return true; } } else if (!requireWriteAccess && Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { return true; } return false; }
From source file:Main.java
public static boolean isExternalStoragePresent(Context context) { boolean externalStorageAvailable; boolean externalStorageWritable; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // We can read and write the media externalStorageAvailable = externalStorageWritable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // We can only read the media externalStorageAvailable = true; externalStorageWritable = false; } else {//from w w w . j a v a2 s . co m // Something else is wrong. It may be one of many other states, but all we need to know is we can neither read nor write externalStorageAvailable = externalStorageWritable = false; } if (!((externalStorageAvailable) && (externalStorageWritable))) { Toast.makeText(context, "SD card not present", Toast.LENGTH_LONG).show(); } return (externalStorageAvailable) && (externalStorageWritable); }
From source file:Main.java
public static boolean storageReady() { String cardstatus = Environment.getExternalStorageState(); if (cardstatus.equals(Environment.MEDIA_REMOVED) || cardstatus.equals(Environment.MEDIA_UNMOUNTABLE) || cardstatus.equals(Environment.MEDIA_UNMOUNTED) || cardstatus.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { return false; } else {/*from www . ja v a 2 s .com*/ return true; } }
From source file:Main.java
static public boolean externalStorageMounted() { 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 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 isExternalStorageAvailableforReading() { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state) || Environment.MEDIA_MOUNTED.equals(state)) { return true; } else {// ww w .j a va 2s .co m return false; } }
From source file:Main.java
/** * Returns the current state of the storage device that provides the given path. * @param state "getExternalStorageState()" */// w ww .j a va2 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
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 {// ww w. j av a 2s. c om if (cardstatus.equals(Environment.MEDIA_MOUNTED)) { return true; } else { return false; } } }
From source file:Main.java
public static void verifyExternalStorageAvailability() { String cardstatus = Environment.getExternalStorageState(); if (cardstatus.equals(Environment.MEDIA_REMOVED) || cardstatus.equals(Environment.MEDIA_UNMOUNTABLE) || cardstatus.equals(Environment.MEDIA_UNMOUNTED) || cardstatus.equals(Environment.MEDIA_MOUNTED_READ_ONLY) || cardstatus.equals(Environment.MEDIA_SHARED)) { RuntimeException e = new RuntimeException( "ODK reports :: SDCard error: " + Environment.getExternalStorageState()); throw e;//from w ww . ja v a 2 s .c om } }
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); }