2015-05-29 101 views

回答

1

您可以在此時設置File對象的初始化路徑。 文件夾=新建文件(「/ sdcard/Photo /」);在這個教程中默認路徑是/ sdcard/photo /在這個地方你可以設置你的路徑然後獲取你的文件。

+0

我已經作出iternal和外部存儲這改變了代碼但沒有得到成功。 – dmkrush

+0

你可以指定路徑可用或不可用? – 2015-05-29 08:58:36

+0

請檢查異常並找到解決方案 – 2015-05-29 08:58:54

0

我辛克這不是好主意,但你可能會寫自己的搜索在手機上的所有文件,例如

public ArrayList<File> getAllphotos(String path){ 
    ArrayList<File> photoPath = new ArrayList<>(); 
    File yourDir = new File(path); 
    for (File f : yourDir.listFiles()) { 
     String mas[] = f.toString().split("\\."); 
     if(mas[mas.length - 1].equalsIgnoreCase("png") || mas[mas.length - 1].equalsIgnoreCase("jpeg")){//or other formats 
      //it is picture 
      photoPath.add(f); 
     } 
    } 
    return photoPath; 
} 

調用此威斯康星

相關問題