List of usage examples for android.os Environment MEDIA_MOUNTED
String MEDIA_MOUNTED
To view the source code for android.os Environment MEDIA_MOUNTED.
Click Source Link
From source file:Main.java
private static boolean checkExternalMedia() { boolean mExternalStorageWriteable = false; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // Can read and write the media mExternalStorageWriteable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { mExternalStorageWriteable = false; } else {// w w w.j av a 2s . co m mExternalStorageWriteable = false; } return mExternalStorageWriteable; }
From source file:Main.java
private static Uri getUri() { String state = Environment.getExternalStorageState(); if (!state.equalsIgnoreCase(Environment.MEDIA_MOUNTED)) return MediaStore.Images.Media.INTERNAL_CONTENT_URI; return MediaStore.Images.Media.EXTERNAL_CONTENT_URI; }
From source file:Main.java
public static boolean hasSDCardMounted() { String state = Environment.getExternalStorageState(); if (state != null && state.equals(Environment.MEDIA_MOUNTED)) { return true; } else {// w w w .j av a 2 s . c o m return false; } }
From source file:Main.java
public static void WriteStringToSD(String fileName, String content) { Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); File file = new File(Environment.getExternalStorageDirectory(), fileName); try {/*from w ww . j a v a2 s .c om*/ FileOutputStream fos = new FileOutputStream(file, true); fos.write(content.getBytes()); fos.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
/** * Check is SD card is ready for read//from w w w.j a v a 2 s . com * * @return */ public static boolean isSDReadable() { String state = Environment.getExternalStorageState(); return Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state); }
From source file:Main.java
/** * Check is SD card is ready for write//from w w w . j a va 2s . co m * * @return */ public static boolean isSDWritable() { String state = Environment.getExternalStorageState(); return Environment.MEDIA_MOUNTED.equals(state); }
From source file:Main.java
/** * @return True if the external storage is writable. False otherwise. *//*from w w w . ja v a 2 s. c o m*/ public static boolean isWritable() { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { return true; } return false; }
From source file:Main.java
private static String createDir(String path) { boolean isHaveSDCard = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); if (!isHaveSDCard) { return null; }/*from ww w .java 2s .c o m*/ File directory = Environment.getExternalStorageDirectory(); File file = new File(directory.getAbsolutePath() + path); if (!file.exists()) { boolean isSuccess = file.mkdirs(); if (isSuccess) { return file.getPath() + File.separator; } else { return null; } } return file.getPath() + File.separator; }
From source file:Main.java
/** * Check SD card/*from w ww .ja v a 2 s.c o m*/ * @return true if SD card is mounted * @author mikewu */ public static boolean isSDCardAvailable() { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) return true; else return false; }
From source file:Main.java
public static File getAppCacheFile(Context context) { File externalCacheDir;/*from w ww .j av a2 s .c om*/ if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) { externalCacheDir = context.getExternalCacheDir(); // context.getExternalCacheDir() maybe null if (externalCacheDir == null) { externalCacheDir = context.getCacheDir(); } } else { externalCacheDir = context.getCacheDir(); } return externalCacheDir; }