1 package com.android.providers.downloads; 2 3 import java.io.File; 4 5 public class FsHelper { 6 7 /** 8 * Deletes all files under a given directory. Deliberately ignores errors, on the assumption 9 * that test cleanup is only supposed to be best-effort. 10 * 11 * @param directory directory to clear its contents 12 */ deleteContents(File directory)13 public static void deleteContents(File directory) { 14 File[] files = directory.listFiles(); 15 if (files != null) { 16 for (File file : files) { 17 if (file.isDirectory()) { 18 deleteContents(file); 19 } 20 file.delete(); 21 } 22 } 23 } 24 } 25