我只是陳述直接變量:Android開發EXTSDCARD命名在不同的設備上?
檔案文件=新的文件(「/ Extsdcard」)
我是愚蠢到認爲所有的Android設備安裝在這個措辭外部設備?
或者我應該使用Environment.getExternalStorageDirectory()。getAbsolutePath();
我的應用程序搜索前三個文件夾層,因此這對功能非常重要。
我只是陳述直接變量:Android開發EXTSDCARD命名在不同的設備上?
檔案文件=新的文件(「/ Extsdcard」)
我是愚蠢到認爲所有的Android設備安裝在這個措辭外部設備?
或者我應該使用Environment.getExternalStorageDirectory()。getAbsolutePath();
我的應用程序搜索前三個文件夾層,因此這對功能非常重要。
String path = Environment.getExternalStorageDirectory().toString()+"/YourDirectory";
Log.d("Files", "enter code herePath: " + path);
File directory = new File(path);
File[] files = directory.listFiles();
//It gives you list of all directoris/files list
Log.d("Files", "Size: "+ files.length);
for (int i = 0; i < 3; i++)
{
Log.d("Files", "FileName:" + files[i].getName());
}
這不是回答問題,是跨設備的標準「/ yourdirectory」名稱「/ EXTSDcard」,是由設備安裝時它的標題如何? – user1477834
Environment.getExternalStorageDirectory()獲取外部驅動器的最高級別。
它返回[external storage]的根目錄(https://commonsware.com/blog/2014/04/08/storage-situation-external-storage.html)。很少有人會將此稱爲「外部驅動器」或「外部設備」,它絕不應該是'/ Extsdcard'。所有這些都傾向於指[可移動存儲](https://commonsware.com/blog/2014/04/09/storage-situation-removable-storage.html),這是獨立的。 – CommonsWare
你的問題是什麼? –