List of usage examples for android.os Environment getExternalStorageState
public static String getExternalStorageState()
From source file:Main.java
public static String getQuranBaseDirectory() { String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) return Environment.getExternalStorageDirectory() + QURAN_BASE; else/*from w w w . j a v a 2s . c om*/ return null; }
From source file:Main.java
public static boolean existSDcard() { String externalStorageState;//from w w w . j a va 2 s . co m try { externalStorageState = Environment.getExternalStorageState(); } catch (NullPointerException e) { // (sh)it happens (Issue #660) externalStorageState = ""; } catch (IncompatibleClassChangeError e) { // (sh)it happens too (Issue #989) externalStorageState = ""; } return MEDIA_MOUNTED.equals(externalStorageState); }
From source file:Main.java
public static final File getDownloadDir(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { return new File(context.getExternalCacheDir(), DOWNLOAD_DIR); }/*ww w .j a v a 2 s . c om*/ return new File(context.getCacheDir(), DOWNLOAD_DIR); }
From source file:Main.java
@SuppressLint("SdCardPath") public static String getSDPath() { File sdDir = null;/* ww w . ja v a 2 s . com*/ boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED); if (sdCardExist) { sdDir = Environment.getExternalStorageDirectory(); } return sdDir.toString(); }
From source file:Main.java
public static String getDiskCacheDir(Context context, String dirName) { final String cachePath = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) ? context.getExternalCacheDir().getPath() : context.getCacheDir().getPath(); return cachePath + File.separator + dirName; }
From source file:Main.java
public static File getDiskCacheDir(Context context, String fileName) { String cachePath;//w w w . j ava 2 s . c o m if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) && !Environment.isExternalStorageRemovable()) { cachePath = context.getExternalCacheDir().getPath(); } else { cachePath = context.getCacheDir().getPath(); } Log.d("bonus", "cachePath = " + cachePath); return new File(cachePath + File.separator + fileName); }
From source file:Main.java
@SuppressLint("NewApi") public static long getFreeDiskSpace() { String status = Environment.getExternalStorageState(); long freeSpace = 0; if (status.equals(Environment.MEDIA_MOUNTED)) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSizeLong(); long availableBlock = stat.getAvailableBlocksLong(); freeSpace = availableBlock * blockSize / 1024; } else {//from w ww . j ava2 s. co m return -1; } return freeSpace; }
From source file:Main.java
public static String getCachePath(Context context, String uniqueName) { String cachePath;/* w w w . j av a2 s . c o 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
/** * Check the external storage status//from www . j av a2s. c o m * * @return */ public static boolean isExternalStorageAvilable() { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { return true; } return false; }
From source file:Main.java
/** * check whether or not ExternalStorage is available * * @return true if externalStorage is available,false otherwise */// w w w . j av a2 s . c o m public static boolean isSDCARDMounted() { return Environment.getExternalStorageState().contentEquals(Environment.MEDIA_MOUNTED); }