码迷,mamicode.com
首页 > 其他好文 > 详细

获取不同机型外置SD卡路径

时间:2014-08-01 13:39:31      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:android   android开发   sdcard   不同机型sd卡路径   

/**
	 * 执行挂载命令,返回挂载的地址。然后将地址解析
	 */
	private void getExtSDCardPath() {
		try {
			Runtime runtime = Runtime.getRuntime();
			Process proc = runtime.exec("mount");
			InputStream is = proc.getInputStream();
			InputStreamReader isr = new InputStreamReader(is);
			String line;
			String mount = new String();
			BufferedReader br = new BufferedReader(isr);
			while ((line = br.readLine()) != null){
				System.out.println(line);
				if (line.contains("secure"))
					continue;
				if (line.contains("asec"))
					continue;
				if (line.contains("fat")){
					String columns[] = line.split(" ");
					if (columns != null && columns.length > 1){
						mount = mount.concat("*" + columns[1] + "\n");
					}
				}else if (line.contains("fuse")){
					String columns[] = line.split(" ");
					if (columns != null && columns.length > 1){
						mount = mount.concat(columns[1] + "\n");
					}
				}
			}
			System.out.printf(mount);
		} catch (FileNotFoundException e) { 
			e.printStackTrace();
		} catch (IOException e) { 
			e.printStackTrace();
		}
	}


该方法运行的结果(测试机--三星Galaxy NoteII):

08-01 12:42:50.790: I/System.out(19890): none /acct cgroup rw,relatime,cpuacct 0 0
08-01 12:42:50.790: I/System.out(19890): tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
08-01 12:42:50.790: I/System.out(19890): tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
08-01 12:42:50.790: I/System.out(19890): none /dev/cpuctl cgroup rw,relatime,cpu 0 0
08-01 12:42:50.790: I/System.out(19890): /dev/block/mmcblk0p13 /system ext4 ro,relatime,barrier=1,data=ordered 0 0
08-01 12:42:50.795: I/System.out(19890): /dev/block/mmcblk0p3 /efs ext4 rw,nosuid,nodev,noatime,barrier=1,journal_async_commit,data=ordered 0 0
08-01 12:42:50.795: I/System.out(19890): /dev/block/mmcblk0p12 /cache ext4 rw,nosuid,nodev,noatime,barrier=1,journal_async_commit,data=ordered 0 0
08-01 12:42:50.795: I/System.out(19890): /dev/block/mmcblk0p16 /data ext4 rw,nosuid,nodev,noatime,barrier=1,journal_async_commit,data=ordered,noauto_da_alloc,discard 0 0
08-01 12:42:50.795: I/System.out(19890): /sys/kernel/debug /sys/kernel/debug debugfs rw,relatime 0 0
08-01 12:42:50.795: I/System.out(19890): /dev/fuse /storage/sdcard0 fuse rw,nosuid,nodev,noexec,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
08-01 12:42:50.795: I/System.out(19890): /dev/block/vold/179:17 /storage/extSdCard vfat rw,dirsync,nosuid,nodev,noexec,noatime,nodiratime,uid=1000,gid=1023,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0


08-01 12:42:50.795: I/System.out(19890): /storage/sdcard0
08-01 12:42:50.795: I/System.out(19890): */storage/extSdCard

获取不同机型外置SD卡路径,布布扣,bubuko.com

获取不同机型外置SD卡路径

标签:android   android开发   sdcard   不同机型sd卡路径   

原文地址:http://blog.csdn.net/maximuskiang/article/details/38334529

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!