Android 7.0 得到存储设备信息
来源:互联网 发布:cms个人网站系统 编辑:程序博客网 时间:2024/06/06 04:53
MountPoint
我们通过MountPoint来描述android设备信息
private static class MountPoint { String mDescription; String mPath; boolean mIsExternal; boolean mIsMounted; long mMaxFileSize; long mFreeSpace; long mTotalSpace; }
实现mMountPathList
private final CopyOnWriteArrayList <MountPoint> mMountPathList = new CopyOnWriteArrayList<MountPoint>(); public void init(Context context) { mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); final String defaultPath = getDefaultPath(); LogUtils.d(TAG, "init,defaultPath = " + defaultPath); if (!TextUtils.isEmpty(defaultPath)) { mRootPath = ROOT_PATH; } mMountPathList.clear(); // check media availability to init mMountPathList StorageVolume[] storageVolumeList = mStorageManager.getVolumeList(); if (storageVolumeList != null) { for (StorageVolume volume : storageVolumeList) { MountPoint mountPoint = new MountPoint(); mountPoint.mDescription = volume.getDescription(context); mountPoint.mPath = volume.getPath(); mountPoint.mIsMounted = isMounted(volume.getPath()); mountPoint.mIsExternal = volume.isRemovable(); mountPoint.mMaxFileSize = volume.getMaxFileSize(); LogUtils.d(TAG, "init,description :" + mountPoint.mDescription + ",path : " + mountPoint.mPath + ",isMounted : " + mountPoint.mIsMounted + ",isExternal : " + mountPoint.mIsExternal + ", mMaxFileSize: " + mountPoint.mMaxFileSize); mMountPathList.add(mountPoint); } } IconManager.getInstance().init(context, defaultPath + SEPARATOR); }
判断是否是外置sdcard
/** * This method checks weather certain path is external mount path. * * @param path path which needs to be checked * @return true for external mount path, and false for not external mount path */ public boolean isExternalMountPath(String path) { //LogUtils.d(TAG, "isExternalMountPath ,path =" + path); if (path == null) { return false; } for (MountPoint mountPoint : mMountPathList) { if (mountPoint.mIsExternal && mountPoint.mPath.equals(path)) { return true; } } return false; }
判断内置存储空间
public boolean isInternalMountPath(String path) { //LogUtils.d(TAG, "isInternalMountPath ,path =" + path); if (path == null) { return false; } for (MountPoint mountPoint : mMountPathList) { if (!mountPoint.mIsExternal && mountPoint.mPath.equals(path)) { return true; } } return false; }
阅读全文
0 0
- Android 7.0 得到存储设备信息
- 得到android设备空间
- Android 获取设备分辨率、设备ID、设备CUP、设备位置、MAC地址、以及存储信息
- Android 获得挂载的存储设备信息
- PhoneGap得到手要设备信息
- 得到存储过程的参数信息
- 得到android的系统信息
- Android设备信息获取
- android 获取设备信息
- Android 获取设备信息
- android获取设备信息
- 获取android设备信息
- android 获取设备信息
- 获取Android设备信息
- android 获取设备信息
- *****Android设备信息获取
- Android设备信息获取
- android设备信息获取
- spring 定时器 @Component 执行两次 问题解决
- 习题 2.4(8) 求方程式 ax^2 + bx + c = 0 的根。
- 标准库类型string
- cocos2d-x解析json文件(C++)
- SpringBoot-Redis
- Android 7.0 得到存储设备信息
- python 使用豆瓣源
- <a></a>链接的css样式
- 阿里巴巴Java面试题锦集
- 系统延时及定时任务
- Thymeleaf的th:href标签失效的一种情况分析及解决方案
- AWS亚马逊云 之access key, secret access key
- C++ 指针 new delete 赋值各种情况总结
- matlab中利用eval和num2str实现struct变量名的递增