當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。