MuntashirAkon/AppManager · error · BackupException
Could not delete the selected backups
Error message
Could not delete the selected backups
What it means
In deleteBackup(), once metadata is read, non-frozen backup items are deleted via backupItem.delete(); if that returns false the method throws BackupException('Could not delete the selected backups'). It means the filesystem refused the delete (returns false, not an exception), typically due to permissions or a frozen/read-only backup.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupManager.java:159
} else {
backupItemList = new ArrayList<>(options.relativeDirs.length);
for (String relativeDir : options.relativeDirs) {
try {
backupItemList.add(BackupItems.findBackupItem(relativeDir));
} catch (IOException e) {
throw new BackupException("Could not get backup files.", e);
}
}
}
for (BackupItems.BackupItem backupItem : backupItemList) {
BackupMetadataV5 metadata;
try {
metadata = backupItem.getMetadata();
} catch (IOException e) {
throw new BackupException("Could not retrieve metadata from backup.", e);
}
if (!backupItem.isFrozen() && !backupItem.delete()) {
throw new BackupException("Could not delete the selected backups");
}
BackupUtils.deleteBackupToDbAndBroadcast(ContextUtils.getContext(), metadata);
}
}
public void verify(@NonNull String relativeDir) throws BackupException {
BackupItems.BackupItem backupItem;
try {
backupItem = BackupItems.findBackupItem(relativeDir);
} catch (IOException e) {
throw new BackupException("Could not get backup files.", e);
}
try (VerifyOp restoreOp = new VerifyOp(backupItem)) {
restoreOp.verify();
}
}
private static int calculateMaxProgress(@NonNull BackupFlags backupFlags) {View on GitHub (pinned to 0152f468fc)
Solutions
- Check mount state and re-mount storage read-write, then retry the delete.
- Grant the app storage/All-files-access permission and retry.
- If files are root-owned, delete them with a root shell or fix ownership first.
- If the backup is intentionally frozen, unfreeze it or remove the frozen entry via the appropriate path (frozen items are skipped by this code).
Example fix
// before
if (!backupItem.isFrozen() && !backupItem.delete()) {
throw new BackupException("Could not delete the selected backups");
}
// after
if (!backupItem.isFrozen()) {
if (!backupItem.delete()) {
Log.w(TAG, "delete failed, is dir read-only? " + backupItem.getDir());
// fallback: recursive delete via File API / root shell
}
} Defensive patterns
Strategy: try-catch
Validate before calling
File d = new File(backupRoot, relDir);
if (!d.canWrite()) {
throw new IllegalStateException("Backup dir not writable: " + d);
} Type guard
boolean backupDeletable(String relDir) {
File d = new File(backupRoot, relDir);
return d.isDirectory() && d.canWrite();
} Try / catch
try {
manager.deleteBackup(options);
} catch (BackupException e) {
if (e.getMessage().contains("Could not delete")) {
// check storage permissions / read-only mount, then retry
}
} Prevention
- Grant All-files-access/storage permission before delete ops
- Ensure storage is mounted read-write
- Avoid root-owned backups if deleting without root
- Unfreeze frozen backups through the proper flow
When it happens
Trigger: deleteBackup() on an unfrozen BackupItem whose delete() returns false — e.g. files on read-only storage, root-owned files, or filesystem-level denial.
Common situations: Backups on a read-only mounted volume; SAF/storage-permission revocation after OS update; backup files owned by root after a root-shell operation; files locked by another process.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Could not create directory ${dataSourceFile}
- Could not retrieve metadata from backup.
- An uninstallation was necessary but couldn't perform it.
- Could not create package staging directory
- Failed to restore the KeyStore files.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/816b1d1d72bb1294.
Report an issue: GitHub.