开发者

Mass/wildcarded file delete on Android

开发者 https://www.devze.com 2023-03-01 15:02 出处:网络
I have a folder with several hundred (up to ~6000) small files. I want to delete all files in that folder (or the whole folder) quickly. Preferably in O(1) time.

I have a folder with several hundred (up to ~6000) small files. I want to delete all files in that folder (or the whole folder) quickly. Preferably in O(1) time.

Is there a way to delete 开发者_JS百科a nonempty folder? Alternatively, is there a way to delete multiple files (specified by a wildcarded name) in one API call?

I know all about File.listFiles() and File.delete(); achieving this functionality per se is easy; I'm after the performance now.

Edit: maybe from C? I already have an NDK library in the project - is there an NDK-supported syscall to that effect?


As CommonsWare said, you won't be able to get around around the fact that deleting/de-referencing files takes time and that can't be circumvented, even using C with the NDK. Just throw it into a background task to free up the UI and hope for the best.

0

精彩评论

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

关注公众号