本文整理汇总了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;
}
}
示例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";
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}