问题
I want to know how to delete a file/folder in SD Card. I tried the code below:
File folder = Environment.getExternalStorageDirectory();
String fileName = folder.getPath() + "/LOST.DIR/ppt52.ppt";
File myFile = new File(fileName);
if(myFile.exists()) {
myFile.delete();
}
but it didn't work.
回答1:
Maybe the folder you are trying to access is Protected. So try to change the access mode before accessing it.
Or you are missing the following permission,
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE
来源:https://stackoverflow.com/questions/8922714/how-to-delete-a-file-folder-in-a-sdcard-under-android-platform