How to delete all files and folders in one folder on Android

前端 未结 12 1028
广开言路
广开言路 2021-01-30 17:52

I use this code to delete all files:

File root = new File(\"root path\");
File[] Files = root.listFiles();
if(Files != null) {
    int j;
    for(j = 0; j < F         


        
12条回答
  •  孤独总比滥情好
    2021-01-30 18:11

    Check this link also Delete folder from internal storage in android?.

    void deleteRecursive(File fileOrDirectory) {
    
        if (fileOrDirectory.isDirectory())
            for (File child : fileOrDirectory.listFiles())
                deleteRecursive(child);
    
        fileOrDirectory.delete();
    
    }
    

提交回复
热议问题