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 File getAlbumDir() { File storageDir = null;/*from ww w. j av a2s . c om*/ if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Telepathy"); if (!storageDir.mkdirs()) { if (!storageDir.exists()) { Log.d("android_utilities", "failed to create directory"); return null; } } } else { Log.d("android_utilities", "External storage is not mounted READ/WRITE."); } return storageDir; }
From source file:Main.java
public static boolean isExternalStoragePresent() { return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()); }
From source file:Main.java
public static String getCacheDir() { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) { File cacheFile = mAppContext.getExternalCacheDir(); if (null != cacheFile) { return cacheFile.getPath(); }/*from ww w . ja v a2 s .c om*/ } return mAppContext.getCacheDir().getPath(); }
From source file:Main.java
public static File getCacheDirectory(Context context) { if (context == null) return null; if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { return context.getExternalCacheDir(); }/*from w w w .j a va2s . c o m*/ return context.getCacheDir(); }
From source file:Main.java
public static boolean isExtStorageAvailable() { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { return true; }//from w ww. jav a 2 s . com return false; }
From source file:Main.java
public static File getDiskCacheDir(Context context, String uniqueName) { final String cachePath = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) ? getExternalCacheDir(context).getPath() : context.getCacheDir().getPath(); return new File(cachePath + File.separator + uniqueName); }
From source file:Main.java
/** * Creates a media file in the {@code Environment.DIRECTORY_PICTURES} directory. The directory * is persistent and available to other applications like gallery. * * @param type Media type. Can be video or image. * @return A file object pointing to the newly created file. */// ww w. j a va2 s . c o m public static File getOutputMediaFile(File myDir) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. Log.i("CameraSample", "about to check state of external storage"); if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { Log.d("CameraSample", "externalstoragestate was " + Environment.getExternalStorageState()); return null; } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile = new File(myDir + File.separator + "VID_" + timeStamp + ".mp4"); return mediaFile; }
From source file:Main.java
@SuppressWarnings("WeakerAccess") public static File getAppCacheDir(Context context) { File appCacheDir = null;//from w w w.j a v a2s . com if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { appCacheDir = context.getExternalCacheDir(); } if (appCacheDir == null) { appCacheDir = context.getCacheDir(); } return appCacheDir; }
From source file:Main.java
public static String getRootFolder(@NonNull Context context) { String rootPath = null;/* w w w .j a v a 2s. com*/ if (android.os.Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { rootPath = Environment.getExternalStorageDirectory().getAbsolutePath(); } else { rootPath = context.getFilesDir().getAbsolutePath(); } return rootPath; }
From source file:Main.java
public static File getCacheDir(Context context) { Log.i("getCacheDir", "cache sdcard state: " + Environment.getExternalStorageState()); if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { File cacheDir = context.getExternalCacheDir(); if (cacheDir != null && (cacheDir.exists() || cacheDir.mkdirs())) { Log.i("getCacheDir", "cache dir: " + cacheDir.getAbsolutePath()); return cacheDir; }//from w ww . j av a2s. c o m } File cacheDir = context.getCacheDir(); Log.i("getCacheDir", "cache dir: " + cacheDir.getAbsolutePath()); return cacheDir; }