我正在使用此代码
public void onClick(DialogInterface dialog, int which) {
File dir = new File (Environment.getExternalStorageDirectory() + "/MyApp/MyFolder");
if (dir.isDirectory())
{
File file = new File(card.imagePath);
file.delete();
}
但它不是从卡中删除文件。有什么想法吗?
答案 0 :(得分:1)
答案 1 :(得分:1)
您确定文件路径吗?
File file = new File(card.imagePath);
if(file.isExists()){
file.delete();
System.out.print("File exists and delete");
} else{
System.out.print("File NOT exists");
}
ADD Permissions ::
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />