Example usage for android.os Environment isExternalStorageRemovable

List of usage examples for android.os Environment isExternalStorageRemovable

Introduction

In this page you can find the example usage for android.os Environment isExternalStorageRemovable.

Prototype

public static boolean isExternalStorageRemovable() 

Source Link

Document

Returns whether the primary shared/external storage media is physically removable.

Usage

From source file:com.gelakinetic.mtgfam.helpers.lruCache.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  ww w .  j av  a 2s.com*/
 */
@TargetApi(VERSION_CODES.GINGERBREAD)
private static boolean isExternalStorageRemovable() {
    return !Utils.hasGingerbread() || Environment.isExternalStorageRemovable();
}

From source file:com.android.leanlauncher.LauncherModel.java

LauncherModel(LauncherAppState app, IconCache iconCache) {
    Context context = app.getContext();

    mAppsCanBeOnRemoveableStorage = Environment.isExternalStorageRemovable();
    mApp = app;//from   w w w. jav a2 s . c o m
    mBgAllAppsList = new AllAppsList(iconCache);
    mIconCache = iconCache;

    final Resources res = context.getResources();
    Configuration config = res.getConfiguration();
    mPreviousConfigMcc = config.mcc;
    mLauncherApps = LauncherAppsCompat.getInstance(context);
    mUserManager = UserManagerCompat.getInstance(context);
}

From source file:com.androidpi.bricks.gallery.lru.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.//from w  w w .j av a 2s  .  c o m
 */
@TargetApi(VERSION_CODES.GINGERBREAD)
public static boolean isExternalStorageRemovable() {
    if (AppUtil.hasGingerbread()) {
        return Environment.isExternalStorageRemovable();
    }
    return true;
}

From source file:com.gdgdevfest.android.apps.devfestbcn.util.ImageLoader.java

/**
 * Get a usable cache directory (external if available, internal otherwise).
 *
 * @param context The context to use/* w  w w. j  a  v  a2s.com*/
 * @param uniqueName A unique directory name to append to the cache dir
 * @return The cache dir
 */
public static File getDiskCacheDir(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

    // TODO: getCacheDir() should be moved to a background thread as it attempts to create the
    // directory if it does not exist (no disk access should happen on the main/UI thread).
    final String cachePath = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable() ? getExternalCacheDir(context).getPath()
                    : context.getCacheDir().getPath();

    return new File(cachePath + File.separator + uniqueName);
}

From source file:com.likou.util.NImageLoader.java

/**
 * Get a usable cache directory (external if available, internal otherwise).
 * /*from   w  w w. java  2 s.  co m*/
 * @param context
 *            The context to use
 * @param uniqueName
 *            A unique directory name to append to the cache dir
 * @return The cache dir
 */
@SuppressLint("NewApi")
public static File getDiskCacheDir(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

    // TODO: getCacheDir() should be moved to a background thread as it
    // attempts to create the
    // directory if it does not exist (no disk access should happen on the
    // main/UI thread).
    final String cachePath = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable() ? getExternalCacheDir(context).getPath()
                    : context.getCacheDir().getPath();

    return new File(cachePath + File.separator + uniqueName);
}

From source file:com.yixia.zi.utils.ImageCache.java

/**
 * Check if external storage is built-in or removable.
 * //from w w  w .j  a v a 2  s.  co m
 * @return True if external storage is removable (like an SD card), false
 * otherwise.
 */
public static boolean isExternalStorageRemovable() {
    return Environment.isExternalStorageRemovable();
}

From source file:com.intelerad.android.portal.ImageCache.java

/**
 * Check if external storage is built-in or removable.
 * //from ww  w .  j a v  a 2s  . co  m
 * @return True if external storage is removable (like an SD card), false otherwise.
 */
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public static boolean isExternalStorageRemovable() {
    if (UiUtils.hasGingerbread()) {
        return Environment.isExternalStorageRemovable();
    }
    return true;
}

From source file:com.egoists.coco_nut.android.cache.ImageCache.java

/**
 * Check if external storage is built-in or removable.
 * /*w ww  .  jav  a2s  .c om*/
 * @return True if external storage is removable (like an SD card), false
 *         otherwise.
 */
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public static boolean isExternalStorageRemovable() {
    if (EtcUtils.hasGingerbread()) {
        return Environment.isExternalStorageRemovable();
    }
    return true;
}

From source file:id.wibisana.priadimulia.imagecaching.cache.ImageCache.java

@TargetApi(9)
public static boolean isExternalStorageRemovable() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        return Environment.isExternalStorageRemovable();
    }//from  w  w  w  . ja  v  a 2 s. com
    return true;
}

From source file:gr.unfold.android.tsibato.images.ImageCache.java

@TargetApi(9)
public static boolean isExternalStorageRemovable() {
    if (Utils.hasGingerbread()) {
        return Environment.isExternalStorageRemovable();
    }// w  w  w. j av a  2 s.  co m
    return true;
}