0
如何在6.0中獲取USB OTG的文件路徑?如何在Android 6.0棉花糖中獲取USB目錄文件路徑?
我無法在USB OTG中獲得Android 6.0的文件路徑,所以讓我知道什麼是解決方案?
感謝, 吉里什
如何在6.0中獲取USB OTG的文件路徑?如何在Android 6.0棉花糖中獲取USB目錄文件路徑?
我無法在USB OTG中獲得Android 6.0的文件路徑,所以讓我知道什麼是解決方案?
感謝, 吉里什
得到這個代碼的所有安裝的設備:
public String getStoragepath() {
try {
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("mount");
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
String line;
String[] patharray = new String[10];
int i = 0;
int available = 0;
BufferedReader br = new BufferedReader(isr);
while ((line = br.readLine()) != null) {
String mount = new String();
if (line.contains("secure"))
continue;
if (line.contains("asec"))
continue;
if (line.contains("fat")) {// TF card
String columns[] = line.split(" ");
if (columns != null && columns.length > 1) {
mount = mount.concat(columns[1] + "/requiredfiles");
patharray[i] = mount;
i++;
// check directory is exist or not
File dir = new File(mount);
if (dir.exists() && dir.isDirectory()) {
// do something here
available = 1;
finalpath = mount;
break;
} else {
}
}
}
}
if (available == 1) {
} else if (available == 0) {
finalpath = patharray[0];
}
} catch (Exception e) {
}
return finalpath;}
其在安卓6.0棉花糖不工作 –