该代码在荣耀1上进行的测试,后来在三星的机子上测试发现结果会有不同,因此在不同机子上会有不同的效果
List<String> list = new ArrayList<>();
InputStream is = null;
InputStreamReader isr = null;
BufferedReader br = null;
try{
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("mount");
is = process.getInputStream();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
String line ;
while((line = br.readLine())!=null){
Log.e("StorageUtil",line);
String result[] = line.split(" ");
line = result[0];
File file = new File(line);
if(file.isDirectory()){
list.add(line);
}
}
if(is!=null){
is.close();
}
if(isr!=null){
isr.close();
}
if(br!=null){
br.close();
}
}catch (Exception e){
e.printStackTrace();
}finally {
}
09-13 22:17:12.600 28504-28504/com.lyp.idcard E/StorageUtil﹕ rootfs / rootfs ro,relatime 0 0
09-13 22:17:12.602 28504-28504/com.lyp.idcard E/StorageUtil﹕ tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0
09-13 22:17:12.604 28504-28504/com.lyp.idcard E/StorageUtil﹕ devpts /dev/pts devpts rw,relatime,mode=600 0 0
09-13 22:17:12.604 28504-28504/com.lyp.idcard E/StorageUtil﹕ none /dev/cpuctl cgroup rw,relatime,cpu 0 0
09-13 22:17:12.605 28504-28504/com.lyp.idcard E/StorageUtil﹕ proc /proc proc rw,relatime 0 0
09-13 22:17:12.606 28504-28504/com.lyp.idcard E/StorageUtil﹕ sysfs /sys sysfs rw,relatime 0 0
09-13 22:17:12.606 28504-28504/com.lyp.idcard E/StorageUtil﹕ none /acct cgroup rw,relatime,cpuacct 0 0
09-13 22:17:12.608 28504-28504/com.lyp.idcard E/StorageUtil﹕ tmpfs /mnt/secure tmpfs rw,relatime,mode=700 0 0
09-13 22:17:12.608 28504-28504/com.lyp.idcard E/StorageUtil﹕ tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
09-13 22:17:12.609 28504-28504/com.lyp.idcard E/StorageUtil﹕ /dev/block/dm-0 /mnt/asec/com.lyp.idcard-1 ext4 ro,dirsync,nosuid,nodev,noatime 0 0
09-13 22:17:12.610 28504-28504/com.lyp.idcard E/StorageUtil﹕ tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
09-13 22:17:12.613 28504-28504/com.lyp.idcard E/StorageUtil﹕ tmpfs /storage/emulated tmpfs rw,relatime,mode=705,uid=1023,gid=1023 0 0
09-13 22:17:12.613 28504-28504/com.lyp.idcard E/StorageUtil﹕ tmpfs /storage/emulated tmpfs rw,nosuid,nodev,relatime,mode=050,gid=1028 0 0
09-13 22:17:12.613 28504-28504/com.lyp.idcard E/StorageUtil﹕ emmc@cust /cust ext4 ro,noatime,data=ordered 0 0
09-13 22:17:12.613 28504-28504/com.lyp.idcard E/StorageUtil﹕ /emmc@android /system ext4 ro,noatime,noauto_da_alloc,commit=1,data=ordered 0 0
09-13 22:17:12.614 28504-28504/com.lyp.idcard E/StorageUtil﹕ /emmc@usrdata /data ext4 rw,nosuid,nodev,noatime,noauto_da_alloc,data=ordered 0 0
09-13 22:17:12.614 28504-28504/com.lyp.idcard E/StorageUtil﹕ tmpfs /data/local_neighbour tmpfs rw,nodev,noatime,nodiratime,size=10240k,mode=755 0 0
09-13 22:17:12.614 28504-28504/com.lyp.idcard E/StorageUtil﹕ /emmc@cache /cache ext4 rw,nosuid,nodev,noatime,noauto_da_alloc,data=ordered 0 0
09-13 22:17:12.614 28504-28504/com.lyp.idcard E/StorageUtil﹕ /emmc@protect_f /protect_f ext4 rw,nosuid,nodev,noatime,nodelalloc,noauto_da_alloc,commit=1,data=ordered 0 0
09-13 22:17:12.614 28504-28504/com.lyp.idcard E/StorageUtil﹕ /emmc@protect_s /protect_s ext4 rw,nosuid,nodev,noatime,nodelalloc,noauto_da_alloc,commit=1,data=ordered 0 0
09-13 22:17:12.614 28504-28504/com.lyp.idcard E/StorageUtil﹕ /dev/block/loop0 /mnt/cd-rom iso9660 ro,relatime 0 0
09-13 22:17:12.614 28504-28504/com.lyp.idcard E/StorageUtil﹕ /dev/fuse /mnt/shell/emulated fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
09-13 22:17:12.615 28504-28504/com.lyp.idcard E/StorageUtil﹕ /dev/block/vold/179:97 /storage/sdcard1 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
09-13 22:17:12.615 28504-28504/com.lyp.idcard E/StorageUtil﹕ tmpfs /storage/sdcard1/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
09-13 22:17:12.615 28504-28504/com.lyp.idcard E/StorageUtil﹕ /dev/fuse /storage/emulated/0 fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
09-13 22:17:12.615 28504-28504/com.lyp.idcard E/StorageUtil﹕ /dev/fuse /storage/emulated/0/Android/obb fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
09-13 22:17:12.615 28504-28504/com.lyp.idcard E/StorageUtil﹕ /dev/fuse /storage/emulated/legacy fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
09-13 22:17:12.615 28504-28504/com.lyp.idcard E/StorageUtil﹕ /dev/fuse /storage/emulated/legacy/Android/obb fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0