List of usage examples for android.os Environment getExternalStorageState
public static String getExternalStorageState()
From source file:Main.java
/** * @param context//from w w w. j a v a2 s .com * @param dirName Only the folder name, not full path. * @return app_cache_path/dirName */ public static String getDiskCacheDir(Context context, String dirName) { String cachePath = null; if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { File externalCacheDir = context.getExternalCacheDir(); if (externalCacheDir != null) { cachePath = externalCacheDir.getPath(); } } if (cachePath == null) { File cacheDir = context.getCacheDir(); if (cacheDir != null && cacheDir.exists()) { cachePath = cacheDir.getPath(); } } return cachePath + File.separator + dirName; }
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"); }//from w w w . j a va2s . co 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"); }/*ww w . 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 www . jav a 2 s .c om return null; }
From source file:Main.java
public static boolean hasExternalStorage() { return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); }
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); }
From source file:Main.java
/** * Checks if external storage is available for read and write. If not, show an error Toast. * /* w w w. j a va 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
/** * 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 a 2s . c om*/ */ 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 hasSDCard() { String status = Environment.getExternalStorageState(); return status.equals(Environment.MEDIA_MOUNTED); }
From source file:Main.java
/** * Check external exist or not.// w w w. j av a 2 s .c om * * @return */ public static boolean hasExternalStorage() { return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); }