Android 如何将文件写入usb内存?(根)
平板电脑的usb插头插入记忆棒,它想访问Android 如何将文件写入usb内存?(根),android,Android,平板电脑的usb插头插入记忆棒,它想访问 try { Runtime.getRuntime().exec("su"); } catch (IOException e) { e.printStackTrace(); } File testFile = new File("mnt/usbhost0"); boolean b1 = testFile.canRead(); //b1 = true boolean b2 = testFile.canWrite(); //b2 = f
try {
Runtime.getRuntime().exec("su");
} catch (IOException e) {
e.printStackTrace();
}
File testFile = new File("mnt/usbhost0");
boolean b1 = testFile.canRead(); //b1 = true
boolean b2 = testFile.canWrite(); //b2 = false
为什么b2是假的
我的设备是根
ps.对不起,我的英语不好。您需要在清单中设置应用程序的权限以写入存储
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
您的su
进程是一个不同的进程,因此不要影响您的访问权限。运行Runtime.getRuntime().exec(“su chmod 777 mnt/usbhost0”)代码>然后检查??我试过。。但我不指望你回答,但我早就知道了