您的位置:首页 > 其它

获取磁盘存储目录

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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: