如何将文件写入USB存储器? (根)

时间:2013-04-01 11:46:05

标签: 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 = false

为什么b2是假的?

我的设备已植根

PS。抱歉我的英语不好..

1 个答案:

答案 0 :(得分:0)

您需要在清单中设置应用的权限才能写入存储空间

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />