尝试获取Android设备上公共文件夹的文件路径并获取其内容 [英] Trying to get a file path to a public folder on android device and get its content
问题描述
我正在寻找获取文件夹的文件路径,然后获取其内容.文件夹是公用文件夹,您只需将设备连接到计算机即可访问这些文件夹.我该如何获取文件路径以访问这些公用文件夹,然后获取其所有内容?
I am looking to get the file path of a folder and then get its content. The folders are a public folder that you can access by just connecting the device into the computer. How do I go about getting a the file path to get access to these public folders and then get all its content?
因此,一旦我将计算机连接到设备,这些便是我看到的文件夹,并且其中有一个显示用于从中获取项目的文件夹",而且我似乎无法弄清楚要访问的文件路径是什么其内容.
So once I connect my computer to the device these are the folders I see and there is one that says "Folder to get items from" and I can't seem to figure what the file path is in order to get access to its content .
这就是我试图获取其内容并记录它们的方法
This is how I'm trying to get its content and Log them
File fileOfEpubs = new File("/data/data/Folder of to get items from/");
File[] dirEpub = fileOfEpubs.listFiles();
if (dirEpub.length != 0){
for (int i = 0; i < dirEpub.length; i++){
String fileName = dirEpub[i].toString();
Log.i("File", "File name = " + fileName);
}
}
推荐答案
您可能需要转义字符串中的空格
You may need to escape the spaces in your string
File fileOfEpubs = new File("/data/data/Folder\ of\ to\ get\ items\ from/");
这篇关于尝试获取Android设备上公共文件夹的文件路径并获取其内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!