android 获取内置存储卡和外置存储卡

本博客所讲的获取内置存储卡和外置存储卡的方式只适用于在/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 device
dev_mount sdcard /storage/sdcard0 emmc@fat /devices/platform/goldfish_mmc.0 /devices/platform/mtk-msdc.0/mmc_host
dev_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_host
dev_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
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

释汐宇辰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值