-1
我在「/ Android/data/Myfolder」中有一個music.mp3文件,我想編寫代碼來檢查是否存在music.mp3文件在Myfolder.Now中,我不知道如何編寫代碼。(android)如何編寫代碼來檢查文件夾中的文件
我在「/ Android/data/Myfolder」中有一個music.mp3文件,我想編寫代碼來檢查是否存在music.mp3文件在Myfolder.Now中,我不知道如何編寫代碼。(android)如何編寫代碼來檢查文件夾中的文件
嘗試使用File
類exists()
方法是這樣的: -
String folderPath = "/Android/data/Myfolder";
String fileName = "music.mp3";
File music = new File(folderPath+"/"+fileName);
if(music.exists()){ // return true if found
System.out.println(fileName +"found");
// other found logics here
}
else {
System.out.println(fileName +" not found here");
// other not found logics here
}
計算器不編寫代碼的服務,請您先幫助自己和谷歌是你的朋友,我們爲您停留在任何階段,問,你會得到一切幫助。 – Shehary
好吧,我會試試 – Adiruj
'「/ Android/data/Myfolder」'。該文件夾/ Android /數據不存在。不在一臺設備上。請先找出真正的路徑。無論如何,你必須使用完整的路徑。 – greenapps