This is also relatively simple, just upload the code
/** * Create a directory file */ public static void createPath(String path) { File file = new File(path); if (!()) { (); } }
Deleting files is relatively simple, but deleting folders is not that simple, especially it contains many sub-files. You need to delete it one by one.
/** * Delete all contents of the folder * */ public void deleteFile(File file) { if (()) { // Determine whether the file exists if (()) { // Determine whether it is a file (); // delete()method You should know It means deletion; } else if (()) { // Otherwise if it is a directory File files[] = (); // Declare all files in the directory files[]; for (int i = 0; i < ; i++) { // Traverse all files in the directory (files[i]); // Put each file 用这个method进行迭代 } } (); } else { // } }
If your files are stored in the SD card, you can check out the previous article first
String filespath = ().getPath(); // Get the path to the private folder
The above method of creating and deleting folders and files on Android is all the content I have shared with you. I hope you can give you a reference and I hope you can support me more.