本文整理匯總了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;
}