캐시 삭제하기
여러가지 내장 컴포넌트들을 사용하다보면 예상하지 못한 캐시가 많이 생성됩니다.
저는 웹뷰를 주로 많이 쓰는데요~ 쓰다보면 내장메모리에 몇메가까지 캐시가 생기더라고요~
webview.clearChache 메써드를 수시로 사용해도 완전히 지워지지 않습니다.
종료시점이나 사용자 메뉴에 아래처럼 쓰시면 바로 0으로 줄어드네요^^
private void clearApplicationCache(java.io.File dir){
if(dir==null)
dir = getCacheDir();
else;
if(dir==null)
return;
else;
java.io.File[] children = dir.listFiles();
try{
for(int i=0;i<children.length;i++)
if(children[i].isDirectory())
clearApplicationCache(children[i]);
else children[i].delete();
}
catch(Exception e){}
}
@Override
public void onDestroy() {
super.onDestroy();
clearApplicationCache(null);
}
캐시 삭제 할 시점
clearApplicationCache(null);
'옛날' 카테고리의 다른 글
UIWeview 링크 새창 (0) | 2015.12.15 |
---|---|
액티비티 life cycle [Android] (0) | 2015.12.15 |
http request (0) | 2015.12.15 |
http post get 전송 (0) | 2015.12.15 |
user agent [IOS] (1) | 2015.12.15 |