2015年5月9日 星期六

[Android] remove files from the specific folder



//remove past thumbnail
String del_path = Environment.getExternalStorageDirectory() + "/Download/IPCam/"+camIDArr[camIndex]+"/thumbnail/";
File dir = new File(del_path); 
Log.e("Environment.getExternalStorageDirectory()+del_path",del_path);
if (dir.isDirectory()) {
 String[] children = dir.list();
 
 for (int i = 0; i < children.length; i++) {
  Log.e("^^^^^^^^^=====>  children["+i+"]",children[i]);     //children[i]   => file name , for example snapshot_20150509140728.jpg
  new File(dir, children[i]).delete();
 } 
} 

沒有留言:

張貼留言