如何在Android 6.0棉花糖中获取USB目录文件路径?

编程入门 行业动态 更新时间:2024-10-09 19:16:24
本文介绍了如何在Android 6.0棉花糖中获取USB目录文件路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何在6.0中获取USB OTG的文件路径?

How to get file path of USB OTG in 6.0?

我无法在USB OTG中获取Android 6.0的文件路径,所以让我知道什么是解决方案?

I am not able to get file path of Android 6.0 in USB OTG so let me know what is solution?

谢谢, 吉里什

推荐答案

通过以下代码获取所有已安装的设备:

get all mounted devices by this code:

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;}

更多推荐

如何在Android 6.0棉花糖中获取USB目录文件路径?

本文发布于:2023-11-27 11:41:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637914.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:棉花   路径   文件   目录   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!