[英]How to get all music files stored in internal storage and external storage in android using MediaStore?
[英]Get all files in all folders in internal and external storage
我正在android studio上的一個項目上工作,需要幫助。如何在內部和外部存儲中的所有文件夾中按文件名搜索文件?
我嘗試使用for循環在內部進行搜索。並且測試了文件是否不存在,該路徑將為舊路徑+文件夾名稱。 它沒有解決
public void getAllDir(File dir) {
String pdfPattern = ".pdf or .txt or .jpg etc..";
File listFile[] = dir.listFiles();
if (listFile != null) {
for (int i = 0; i < listFile.length; i++) {
if (listFile[i].isDirectory()) {
getAllDir(listFile[i]);
} else {
if (listFile[i].getName().endsWith(pdfPattern)){
//Do what ever u want
}
}
}
}
}
and call this function like
getAllDir(Environment.getExternalStorageDirectory());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.