List of usage examples for android.os Environment isExternalStorageRemovable
public static boolean isExternalStorageRemovable()
From source file:com.boko.vimusic.cache.ImageCache.java
/** * Check if external storage is built-in or removable * // ww w. ja v a2 s . c om * @return True if external storage is removable (like an SD card), false * otherwise */ public static final boolean isExternalStorageRemovable() { return Environment.isExternalStorageRemovable(); }
From source file:com.apptentive.android.sdk.util.Util.java
/** * This function launchs the default app to view the selected file, based on mime type * * @param sourcePath/*from w w w . java2 s . c om*/ * @param selectedFilePath the full path to the local storage * @param mimeTypeString the mime type of the file to be opened * @return true if file can be viewed */ public static boolean openFileAttachment(final Context context, final String sourcePath, final String selectedFilePath, final String mimeTypeString) { if ((Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) && hasPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { File selectedFile = new File(selectedFilePath); String selectedFileName = null; if (selectedFile.exists()) { selectedFileName = selectedFile.getName(); final Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); /* Attachments were downloaded into app private data dir. In order for external app to open * the attachments, the file need to be copied to a download folder that is accessible to public * The folder will be sdcard/Downloads/apptentive-received/<file name> */ File downloadFolder = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); File apptentiveSubFolder = new File(downloadFolder, "apptentive-received"); if (!apptentiveSubFolder.exists()) { apptentiveSubFolder.mkdir(); } File tmpfile = new File(apptentiveSubFolder, selectedFileName); String tmpFilePath = tmpfile.getPath(); // If destination file already exists, overwrite it; otherwise, delete all existing files in the same folder first. if (!tmpfile.exists()) { String[] children = apptentiveSubFolder.list(); if (children != null) { for (int i = 0; i < children.length; i++) { new File(apptentiveSubFolder, children[i]).delete(); } } } if (copyFile(selectedFilePath, tmpFilePath) == 0) { return false; } intent.setDataAndType(Uri.fromFile(tmpfile), mimeTypeString); try { context.startActivity(intent); return true; } catch (ActivityNotFoundException e) { ApptentiveLog.e("Activity not found to open attachment: ", e); } } } else { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(sourcePath)); if (Util.canLaunchIntent(context, browserIntent)) { context.startActivity(browserIntent); } } return false; }
From source file:us.happ.bitmap.ImageCache.java
/** * Check if external storage is built-in or removable. * * @return True if external storage is removable (like an SD card), false * otherwise.//from www . j a v a 2 s . c o m */ @TargetApi(9) public static boolean isExternalStorageRemovable() { if (Happ.hasGingerbread) { return Environment.isExternalStorageRemovable(); } return true; }
From source file:com.wetrain.client.customviews.imagecache.ImageCache.java
/** * Check if external storage is built-in or removable. * * @return True if external storage is removable (like an SD card), false * otherwise.// w ww . j ava 2 s. co m */ @TargetApi(9) public static boolean isExternalStorageRemovable() { if (Utills.hasGingerbread()) { return Environment.isExternalStorageRemovable(); } return true; }
From source file:com.androidsx.imagesearch.util.ImageCache.java
/** * Check if external storage is built-in or removable. * * @return True if external storage is removable (like an SD card), false * otherwise./*from w w w . j ava 2 s. c o m*/ */ @TargetApi(9) public static boolean isExternalStorageRemovable() { if (Platform.hasGingerbread()) { return Environment.isExternalStorageRemovable(); } return true; }
From source file:com.nf2m.util.ImageCache.java
/** * Get UriObserver usable cache directory (external if available, internal otherwise). * * @param context The context to use//from ww w.ja v a 2 s. co m * @param uniqueName A unique directory name to append to the cache dir * @return The cache dir */ @NonNull static File getDiskCacheDir(@NonNull Context context, String uniqueName) { // Check if media is mounted or storage is built-in, if so, try and use external cache dir // otherwise use internal cache dir String cachePath = null; // you still need a default value if not mounted if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) { if (getExternalCacheDir(context) != null) { cachePath = getExternalCacheDir(context).getPath(); // most likely your null value } } else { if (context.getCacheDir() != null) { cachePath = context.getCacheDir().getPath(); } } return new File(cachePath + File.separator + uniqueName); }
From source file:com.rp.justcast.photos.ImageCache.java
/** * Check if external storage is built-in or removable. * * @return True if external storage is removable (like an SD card), false * otherwise./* ww w. jav a 2 s . c o m*/ */ @TargetApi(VERSION_CODES.GINGERBREAD) public static boolean isExternalStorageRemovable() { if (JustCastUtils.hasGingerbread()) { return Environment.isExternalStorageRemovable(); } return true; }
From source file:wb.android.cache.ImageCache.java
/** * Check if external storage is built-in or removable. * * @return True if external storage is removable (like an SD card), false * otherwise.// w w w. ja v a2 s . co m */ @TargetApi(VERSION_CODES.GINGERBREAD) public static boolean isExternalStorageRemovable() { if (Utils.ApiHelper.hasGingerbread()) { return Environment.isExternalStorageRemovable(); } return true; }
From source file:prince.app.sphotos.util.ImageCache.java
/** * Check if external storage is built-in or removable. * * @return True if external storage is removable (like an SD card), false * otherwise.//ww w. j a v a 2 s . com */ @TargetApi(VERSION_CODES.GINGERBREAD) public static boolean isExternalStorageRemovable() { if (Global.hasGingerbread()) { return Environment.isExternalStorageRemovable(); } return true; }
From source file:com.android.fragmentbase.cache.ImageCache.java
/** * Check if external storage is built-in or removable. * * @return True if external storage is removable (like an SD card), false * otherwise./*ww w .j ava 2 s .c o m*/ */ @TargetApi(VERSION_CODES.GINGERBREAD) public static boolean isExternalStorageRemovable() { if (ImageUtils.hasGingerbread()) { return Environment.isExternalStorageRemovable(); } return true; }