String path = Environment.getExternalStorageDirectory().getPath() + AppConstant.FILE_PATH + "/" + apkName ;File file = new File(path);deleteApk(path);
/*** 删除其他版本安装包*/public void deleteApk(String abpath) {String[] ss = abpath.split("/");String name = ss[ss.length - 1];String path = abpath.replace("/" + name, "");File file = new File(path);// 里面输入特定目录File temp = null;File[] filelist = file.listFiles();for (int i = 0; i < filelist.length; i++) {temp = filelist[i];if (temp.getName().endsWith("apk") && !temp.getName().endsWith(name))// 获得文件名,如果后缀为“”,这个你自己写,就删除文件{temp.delete();// 删除文件}}}}