본문 바로가기
Android

Android filesDir.path 폴더 안에 하위 목록까지 삭제하기

by kkong93 2022. 9. 27.
반응형
    private fun removeAllSummaryLogFile() {
        val file = File(filesDir.path + SUMMARY_FILE_PATH)
        val fileList = file.listFiles()
        if (file.exists()) {
            if (fileList != null) {
                for (i in fileList.indices) {
                    if (fileList[i].exists()) {
                        fileList[i].delete()
                    }
                }
            }
        }
    }

listFiles()로 하위 목록을 가져온 뒤 하나씩 지워준다.

반응형

댓글