获取磁盘存储目录
2014-05-16 17:39
169 查看
/**
* Get a usable cache directory (external if available, internal otherwise).
*
* @param context The context to use
* @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
final String cachePath =
Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) ||
!isExternalStorageRemovable() ? getExternalCacheDir(context).getPath() :
context.getCacheDir().getPath();
return new File(cachePath + File.separator + uniqueName);
}
* Get a usable cache directory (external if available, internal otherwise).
*
* @param context The context to use
* @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
final String cachePath =
Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) ||
!isExternalStorageRemovable() ? getExternalCacheDir(context).getPath() :
context.getCacheDir().getPath();
return new File(cachePath + File.separator + uniqueName);
}
相关文章推荐
- 获取data目录剩余存储空间大小,并格式化字符串
- PHP学习笔记——目录,文件,磁盘信息获取
- Python获取当前目录下所有文件的绝对路径并存储在文件中
- Android 4.0以后正确的获取外部sd卡存储目录
- 获取Android应用专属缓存存储目录
- SQL Server2005中获取在磁盘上建立目录的权限
- android获取存储目录(路径)的几种方式和注意事项
- Android下获取各种存储目录
- 获取Android中的内部和外部数据存储目录
- Android使用Linux mount获取SdCard存储目录
- vmware station中 UDEV 无法获取共享存储磁盘的UUID,症状: scsi_id -g -u -d /dev/sdb 无返回结果。
- SDK获取系统目录信息,并存储到文件
- 获取指定目录下指定扩展名文件的绝对路径,存储到文本文件中
- 使用批处理+WMI获取指定文件或目录所在的物理磁盘信息
- 数据存储:获取文件目录
- Win32 获取磁盘剩余空间+遍历文件目录+wchar_t与char互转
- 项目图片上传存储的目录部分代码思路Calendar类获取年月日
- Android下获取各种存储目录
- C#获取当前系统磁盘符、系统目录、桌面等
- vmware station中 UDEV 无法获取共享存储磁盘的UUID,症状: scsi_id -g -u -d /dev/sdb 无返回结果。