当前位置: 首页>>代码示例>>Java>>正文


Java Environment.isExternalStorageRemovable方法代码示例

本文整理汇总了Java中android.os.Environment.isExternalStorageRemovable方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.isExternalStorageRemovable方法的具体用法?Java Environment.isExternalStorageRemovable怎么用?Java Environment.isExternalStorageRemovable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.Environment的用法示例。


在下文中一共展示了Environment.isExternalStorageRemovable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDiskCacheDir

import android.os.Environment; //导入方法依赖的package包/类
public static String getDiskCacheDir(Context context) {
    File cacheFile = null;
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        cacheFile = context.getExternalCacheDir();
    } else {
        cacheFile = context.getCacheDir();
    }
    if (cacheFile != null) {
        return cacheFile.getPath();
    } else {
        String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
        return Environment.getExternalStorageDirectory().getPath() + cacheDir;
    }
}
 
开发者ID:redleaf2002,项目名称:magic_imageloader_network,代码行数:16,代码来源:DiskUtils.java

示例2: SHOWFILEURL

import android.os.Environment; //导入方法依赖的package包/类
public static final String SHOWFILEURL(Context context) throws IOException
{
    String cachePath;
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        cachePath = context.getExternalCacheDir().getPath();
    } else {
        cachePath =context.getCacheDir().getPath();
    }
    File file = new File(cachePath+"/thumb");
    if (!file.exists()) {
        try {
            file.mkdirs();
        } catch (Exception e) {
        }
    }
    return cachePath+File.separator+"thumb";
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:19,代码来源:UtilImags.java

示例3: getDiskCacheDir

import android.os.Environment; //导入方法依赖的package包/类
public static String getDiskCacheDir(Context context) {
    String cacheDir;

    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
        && !Environment.isExternalStorageRemovable()) {
        cacheDir = getExternalCacheDir(context);
        // 部分机型返回了null
        if (cacheDir == null) {
            cacheDir = getInternalCacheDir(context);
        }
    } else {
        cacheDir = getInternalCacheDir(context);
    }
    if(!checkCacheAvailable(cacheDir)){
        return getBackUpPath(context);
    }
    return cacheDir;
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:19,代码来源:XulSystemUtil.java

示例4: getDiskCacheDir

import android.os.Environment; //导入方法依赖的package包/类
private static File getDiskCacheDir(Context context, String dirName) {
    String cachePath;
    if ((Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable())
            && context.getExternalCacheDir() != null) {
        cachePath = context.getExternalCacheDir().getPath();
    } else {
        cachePath = context.getCacheDir().getPath();
    }
    return new File(cachePath + File.separator + dirName);
}
 
开发者ID:qiaodashaoye,项目名称:SuperHttp,代码行数:12,代码来源:DiskCache.java

示例5: getDiskCacheDir

import android.os.Environment; //导入方法依赖的package包/类
/**
 * 获取缓存目录
 *
 * @param context
 * @return
 */
public static String getDiskCacheDir(Context context) {
    String cachePath = null;
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        cachePath = context.getExternalCacheDir().getPath();
    } else {
        cachePath = context.getCacheDir().getPath();
    }
    return cachePath;
}
 
开发者ID:ChunweiDu,项目名称:Utils,代码行数:17,代码来源:FileUtil.java

示例6: getDiskCacheDir

import android.os.Environment; //导入方法依赖的package包/类
/**
 * 通过context获取APP缓存文件夹路径,用于缓存数据
 *
 * @param context
 * @return
 */
private String getDiskCacheDir(Context context) {
    String cachePath;
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        cachePath = context.getExternalCacheDir().getPath();
    } else {
        cachePath = context.getCacheDir().getPath();
    }
    return cachePath;
}
 
开发者ID:ymqq,项目名称:CommonFramework,代码行数:17,代码来源:CrashCaptureHandler.java

示例7: getDiskCachePath

import android.os.Environment; //导入方法依赖的package包/类
private String getDiskCachePath(Context context) {
    String cachePath;
    if ((Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable())
            && context.getExternalCacheDir() != null) {
        cachePath = context.getExternalCacheDir().getPath();
    } else {
        cachePath = context.getCacheDir().getPath();
    }
    return cachePath;
}
 
开发者ID:qiaodashaoye,项目名称:SuperHttp,代码行数:12,代码来源:DownloadRequest.java

示例8: isExternalStorageAvailable

import android.os.Environment; //导入方法依赖的package包/类
public static boolean isExternalStorageAvailable() {
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:8,代码来源:Utils.java

示例9: isExternalStorageRemovable

import android.os.Environment; //导入方法依赖的package包/类
/**
 * Check if external storage is built-in or removable.
 *
 * @return True if external storage is removable (like an SD card), false
 *         otherwise.
 */
@TargetApi(VERSION_CODES.GINGERBREAD)
public static boolean isExternalStorageRemovable() {
    if (Utils.hasGingerbread()) {
        return Environment.isExternalStorageRemovable();
    }
    return true;
}
 
开发者ID:jjuiddong,项目名称:Android-Practice,代码行数:14,代码来源:ImageCache.java

示例10: getDiskCacheDir

import android.os.Environment; //导入方法依赖的package包/类
/**
 * 应用程序缓存原理:
 * 1.当SD卡存在或者SD卡不可被移除的时候,就调用getExternalCacheDir()方法来获取缓存路径,否则就调用getCacheDir()方法来获取缓存路径<br>
 * 2.前者是/sdcard/Android/data/<application package>/cache 这个路径<br>
 * 3.后者获取到的是 /data/data/<application package>/cache 这个路径<br>
 *
 * @param uniqueName 缓存目录
 */
public File getDiskCacheDir(Context context, String uniqueName) {
    File cacheDir;
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        cacheDir = context.getExternalCacheDir();
    } else {
        cacheDir = context.getCacheDir();
    }
    if (cacheDir == null) {// if cacheDir is null throws NullPointerException
        cacheDir = context.getCacheDir();
    }
    return new File(cacheDir.getPath() + File.separator + uniqueName);
}
 
开发者ID:zhou-you,项目名称:RxEasyHttp,代码行数:22,代码来源:RxCache.java

示例11: getDiskCacheDir

import android.os.Environment; //导入方法依赖的package包/类
private String getDiskCacheDir(Context context, String dirName) {
    String cachePath = "";
    if ((Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable())
            && context != null && context.getExternalCacheDir() != null) {
        cachePath = context.getExternalCacheDir().getPath();
    } else {
        if (context != null && context.getCacheDir() != null) {
            cachePath = context.getCacheDir().getPath();
        }
    }
    return cachePath + File.separator + dirName;
}
 
开发者ID:xiaoyaoyou1212,项目名称:ViseFace,代码行数:14,代码来源:FaceDetectorActivity.java

示例12: isExternalStorageRemovable

import android.os.Environment; //导入方法依赖的package包/类
/**
 * Check if external storage is built-in or removable.
 * 
 * @return True if external storage is removable (like an SD card), false
 *         otherwise.
 */
@TargetApi(VERSION_CODES.GINGERBREAD)
public static boolean isExternalStorageRemovable() {
	if (Utils.hasGingerbread()) {
		return Environment.isExternalStorageRemovable();
	}
	return true;
}
 
开发者ID:liuyanggithub,项目名称:SuperSelector,代码行数:14,代码来源:ImageCache.java

示例13: getFileDir

import android.os.Environment; //导入方法依赖的package包/类
public static File getFileDir(Context context) {
    File fileDir;
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        fileDir = context.getExternalFilesDir(null);
        if(fileDir == null)
            fileDir = context.getFilesDir();
    } else {
        fileDir = context.getFilesDir();
    }
    return fileDir;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:13,代码来源:SysUtils.java

示例14: getDiskCacheDir

import android.os.Environment; //导入方法依赖的package包/类
/**
 * 获取硬盘的缓存目录,用来放图片
 * http://blog.csdn.net/u011494050/article/details/39671159
 * @param context context
 * @return 路径
 */
private static String getDiskCacheDir(Context context) {
    String cachePath = null;
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        try{
            cachePath = context.getExternalCacheDir().getPath();//SDCard/Android/data/应用包名/cache/目录
        }catch (NullPointerException e){
            cachePath = context.getCacheDir().getPath();    //data/data/<application package>/cache
        }
    } else {
        cachePath = context.getCacheDir().getPath();    //data/data/<application package>/cache
    }
    return cachePath;
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:21,代码来源:FileUtils.java

示例15: getDiskFileDir

import android.os.Environment; //导入方法依赖的package包/类
/**
 * 获取缓存视频文件目录
 *
 * @param context
 * @return
 */
public static String getDiskFileDir(Context context) {
    String cachePath = null;
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) {
        cachePath = context.getExternalFilesDir(Environment.DIRECTORY_MOVIES).getPath();
    } else {
        cachePath = context.getFilesDir().getPath();
    }
    return cachePath;
}
 
开发者ID:ChunweiDu,项目名称:Utils,代码行数:16,代码来源:FileUtil.java


注:本文中的android.os.Environment.isExternalStorageRemovable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。