开发者

Alternative to recursive file deletion in directories?

//Check that external storage is mounted and accessable
    String accessable = Environment.getExternalStorageState();
    if (!Environment.MEDIA_MOUNTED.equals(accessable)) {
        buildWarningMessage();
    }

//Set the cache directory
        CACHE_DIRECTORY = externalRoot + "/folder/.cache/";



@Override
    protected void onDestroy() {
        super.onDestroy();
        File cacheFile = new File(CACHE_DIRECTORY);
        if (cacheFile.exists()) {
            deleteDir(cacheFile);
        }

I'm currently using the above code to create a folder whic开发者_如何学Ch is used to temporarily store images that the app uses later. deleteDir is just a generic recursive file deletion to empty a directory. Is there a better way to do this than to delete everything? Ideally I just want a temp folder that empties when the application closes.


hi Daniel you have to delete all your folder files before to delete your folder, (recursive file deletion) thats the only way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜