Well, what else can I say.
Test 1
File dir = new File("/system");
if(dir.canRead() && dir.canWrite()) {
System.out.println("Can read and write in this directory. (rw)");
} else if(dir.canRead()) {
System.out.println("Can read in this directory (r)");
} else if(dir.canWrite()) {
System.out.println("Can write in this directory (w).");
}
Output
Can read in this directory (r)
$ mount | grep '/system'
/dev/block/platform/13540000.dwmmc0/by-name/SYSTEM /system ext4 ro,seclabel,relatime,norecovery 0 0
Test 2
dir = new File("/storage/emulated/0");
if(dir.canRead() && dir.canWrite()) {
System.out.println("Can read and write in this directory. (rw)");
} else if(dir.canRead()) {
System.out.println("Can read in this directory (r)");
} else if(dir.canWrite()) {
System.out.println("Can write in this directory (w).");
}
Output
Can read and write in this directory. (rw)
$ mount | grep '/storage/emulated'
/data/media /storage/emulated sdcardfs rw,seclabel,nosuid,nodev,noexec,relatime,low_uid=1023,low_gid=1023,gid=9997,multi_user,mask=0007,reserved=20MB 0 0
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…