Java tutorial
//package com.java2s; import java.io.File; import java.util.List; import android.os.Environment; public class Main { public static String BACKUPPATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/.java2s/java2sMarket/backup/"; public static void deleteNoBackupApk(List<String> apkNames) { boolean isExist; File directory = new File(BACKUPPATH); if (directory.exists()) { File[] files = directory.listFiles(); for (int i = 0; i < files.length; i++) { isExist = false; for (int j = 0; j < apkNames.size(); j++) { String tempName = files[i].getName(); tempName = tempName.substring(0, tempName.length() - 4); if (tempName.equals(apkNames.get(j))) { isExist = true; break; } } if (!isExist) { files[i].delete(); } } } } }