find Photo From SDCard - Android android.hardware

Android examples for android.hardware:Photo

Description

find Photo From SDCard

Demo Code

import java.io.File;

public class Main {

  public static boolean findPhotoFromSDCard(String path, String photoName) {
    boolean flag = false;

    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
      File dir = new File(path);
      if (dir.exists()) {
        File folders = new File(path);
        File photoFile[] = folders.listFiles();
        for (int i = 0; i < photoFile.length; i++) {
          String fileName = photoFile[i].getName().split("\\.")[0];
          if (fileName.equals(photoName)) {
            flag = true;/* w w  w  . ja  v a2  s .c  o  m*/
          }
        }
      } else {
        flag = false;
      }

    } else {
      flag = false;
    }
    return flag;
  }

}

Related Tutorials