How to delete entire contents of sdcard programmatically in Android 2.2

微笑、不失礼 提交于 2019-11-28 11:42:43
Peter Knego
  1. You can delete directories with Java. You have to do it recursively if they are not empty: http://www.exampledepot.com/egs/java.io/DeleteDir.html

  2. No. All applications have full RW access to external storage.

  3. Yes you can execute shell commands (but you'll have to check if "rm" is available): Any way to run shell commands on android programmatically?

Checking for available commands: How can I get information from the shell about commands available in Android shell?

Don't run shell commands, they are not part of the SDK. There is a good chance your app will break on some devices that don't have whatever shell command you are running. It is easy to use the Java file APIs to iterate through all files and delete them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!