2015-07-19 42 views
-1

我在「/ Android/data/Myfolder」中有一個music.mp3文件,我想編寫代碼來檢查是否存在music.mp3文件在Myfolder.Now中,我不知道如何編寫代碼。(android)如何編寫代碼來檢查文件夾中的文件

+1

計算器不編寫代碼的服務,請您先幫助自己和谷歌是你的朋友,我們爲您停留在任何階段,問,你會得到一切幫助。 – Shehary

+0

好吧,我會試試 – Adiruj

+0

'「/ Android/data/Myfolder」'。該文件夾/ Android /數據不存在。不在一臺設備上。請先找出真正的路徑。無論如何,你必須使用完整的路徑。 – greenapps

回答

1

嘗試使用Fileexists()方法是這樣的: -

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 
     } 
相關問題