만약 SD카드안에 image라는 폴더가 있으면 그 폴더 안에있는 전체 파일의 사이즈를 가져오고 싶습니다File file = new File("/sdcard/image/")이런식으로 가져올 수 있을까 했는데 방법을 못찾겠습니다 도움 부탁드립니다
음 'ㅡ' API 가 따로 있는지는 잘 모르겠구요. file.length() 함수와 file.isDirectory() 함수가 있어요..private int getDirectorySize(String rootPath){ int result = 0; File f = new File("rootpath"); if( !f.exist()) return 0; String[] fileList = f.list(); if (fileList == null) return 0; for( String path : fileList ) { File f2 = new File("path"); if( f2.isDirectory()) result += getDirectorySize(path); else result += f.length(); } return result;}제대로 돌아 갈지는 미지수지만. 엇비슷 할 것 같습니다.
로그인 유지
음 'ㅡ'
API 가 따로 있는지는 잘 모르겠구요. file.length() 함수와 file.isDirectory() 함수가 있어요..
private int getDirectorySize(String rootPath)
{
int result = 0;
File f = new File("rootpath");
if( !f.exist())
return 0;
String[] fileList = f.list();
if (fileList == null)
return 0;
for( String path : fileList )
{
File f2 = new File("path");
if( f2.isDirectory())
result += getDirectorySize(path);
else
result += f.length();
}
return result;
}
제대로 돌아 갈지는 미지수지만. 엇비슷 할 것 같습니다.