android 获取内置存储卡和外置存储卡
来源:互联网 发布:js改变button标签文字 编辑:程序博客网 时间:2024/06/10 19:04
本博客所讲的获取内置存储卡和外置存储卡的方式只适用于在/system/etc文件夹中有 vold.fstab文件的手机
,我的手机该文件内容如下:
## Vold 2.0 Generic fstab## - San Mehat (san@android.com)## ######################### Regular device mount#### Format: dev_mount <label> <mount_point> <part> <sysfs_path1...> ## label - Label for the volume## mount_point - Where the volume will be mounted## part - Partition # (1 based), or 'auto' for first usable partition.## <sysfs_path> - List of sysfs paths to source devices######################## Example of a standard sdcard mount for the emulator / Dream# Mounts the first usable partition of the specified devicedev_mount sdcard /storage/sdcard0 emmc@fat /devices/platform/goldfish_mmc.0 /devices/platform/mtk-msdc.0/mmc_hostdev_mount sdcard2 /storage/sdcard1 auto /devices/platform/goldfish_mmc.1 /devices/platform/mtk-msdc.1/mmc_host## Example of a dual card setup# dev_mount left_sdcard /mnt/sdcard1 auto /devices/platform/goldfish_mmc.0 /devices/platform/mtk-sd.0/mmc_host/mmc0# dev_mount right_sdcard /mnt/sdcard2 auto /devices/platform/goldfish_mmc.1 /devices/platform/mtk-sd.2/mmc_host/mmc2## Example of specifying a specific partition for mounts# dev_mount sdcard /mnt/sdcard 2 /devices/platform/goldfish_mmc.0 /devices/platform/msm_sdcc.2/mmc_host/mmc1重要的是这两句话
dev_mount sdcard /storage/sdcard0 emmc@fat /devices/platform/goldfish_mmc.0 /devices/platform/mtk-msdc.0/mmc_hostdev_mount sdcard2 /storage/sdcard1 auto /devices/platform/goldfish_mmc.1 /devices/platform/mtk-msdc.1/mmc_host
这个emmc@fat表示的是存储卡的类型是内置的,auto指的是存储卡是外置的,
/storage/sdcard0
/storage/sdcard1
分别表示的是内置存储卡和外置存储卡的根路径,
下面我直接上代码了<span style="white-space:pre"></span>
</pre><p><pre name="code" class="java"><span style="white-space:pre"></span>br=new BufferedReader(new FileReader(new File("/system/etc/vold.fstab")));StringBuilder sb=new StringBuilder("");String line=null;while((line=br.readLine())!=null){String[]strtmp=line.split(" ");if(strtmp.length>0){if(strtmp[0].equals("dev_mount")){if(strtmp[3].equals("emmc@fat")){Log.e("emmc@fat", "内置存储卡");menu.addSubMenu("内置存储卡");filepath.add(strtmp[2]);//根路径}else if(strtmp[3].equals("auto")){Log.e("auto", "外置存储卡");menu.addSubMenu("外置存储卡");filepath.add(strtmp[2]);///根路径}}}}
0 0
- android 获取内置存储卡和外置存储卡
- Android获取外置存储卡、内置存储卡路径
- Android 获取内置和外置存储卡的路径及总共、可用空间
- 获取内置和外置存储路径
- android开发关于和使用本机内存,内置存储卡和外置存储卡
- Android 获取内外置存储卡方法
- Android 获取内外置存储卡方法
- Android 获取内外置存储卡方法
- Android 获取内外置存储卡方法
- Android 获取内外置存储卡方法
- Android 通过反射调用获取内置存储和外置sd卡根路径(适用于各个版本)
- Android获取机身存储、内置SD卡与外置TF卡路径
- Android获取内置/外置存储卡位置以及大小(支持6.0)
- 论Android的内置存储、外置存储和系统内存
- Android获取不同手机 自身存储和外置SD卡存储路径的解决方案
- android开发关于和使用本机内存,内置存储卡和外置存储卡大揭秘
- android开发关于和使用本机内存,内置存储卡和外置存储卡大揭秘
- 如何区分手机内置存储卡与外置存储卡
- 有趣的C语言问答
- Intent MIME type介绍
- vision引擎中 地形几何网格导出
- java8的一点感觉和个人看法
- cocos2d-x-3.2 不能混合颜色修改
- android 获取内置存储卡和外置存储卡
- Nginx配置参数说明
- volatile
- Android 开源框架Universal-Image-Loader完全解析(二)--- 图片缓存策略详解
- 【先锋】APICloud是一朵面对移动开发的PaaS云
- Android的四大组件之ContentProvider总结
- 如何配置vi配置文件
- SIP协议概述
- linux date 格式化时间和日期