안드로이드 내부저장소(Internal Storage) 사용량 구하기 , 저장소 전체용량 , 저장소 사용가능 용량
MainActivity.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //내부저장소(Internal Storage) 사용량 구하기 public String getInternalUsageRate(){ String path = Environment.getDataDirectory().getAbsolutePath(); StatFs stat = new StatFs(path); long blockSize = stat.getBlockSizeLong(); //API 18부터 //전체 Internal Storage 크기 long totalSize = stat.getBlockCountLong() * blockSize; //API 18부터 //사용가능한 Internal Storage 크기 long availableSize = stat.getAvailableBlocksLong() * blockSize; //API 18부터 //사용량 DecimalFormat df = new DecimalFormat("#,###"); double storage = 100.0*(totalSize-availableSize)/totalSize; return df.format(storage)+"%"; } | cs |
결과
'IT > - 프로그래밍' 카테고리의 다른 글
안드로이드 프레그먼트(Fragment) 예제 (0) | 2016.08.15 |
---|---|
안드로이드 CPU Core 개수 구하기 (0) | 2016.08.13 |
안드로이드 RAM 사용량 구하기 (0) | 2016.08.13 |
안드로이드 layout폴더를 서브폴더로 나누기 (0) | 2016.08.13 |
안드로이드 String으로된 Color값을 Int로 바꾸기 (0) | 2016.08.10 |