나는 그 다음 문제가 있습니다. 내 응용 프로그램은 파일 목록을 읽고 사용자에게 이름을 보여줘야합니다. 앱을 처음 시작하면 앱의 특정 폴더를 만들어야합니까? 그러면 비어 있는지 어떻게 확인할 수 있습니까?폴더가 비어 있는지 확인하십시오 (내부 저장소)
// check if appfolder is created and if not through an
// exception
File path = new File("yourDir");
if (!path.exists()) {
if (!path.mkdirs()) {
try {
throw new IOException(
"Application folder can not be created. Please check if your memory is writable and healthy and then try again.");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
} else {
Log.i("app", "directory is: " + path.getPath());
}
exists()
검사를 경로가 존재 여부와 path.exists()
은 단순히 당신을 위해 하나를 만드는 경우 : 오류가 하나를 만드는 경우 하나를 생성하고 경고하지 않을 경우