diff --git a/app/src/main/java/com/battlelancer/seriesguide/dataliberation/JsonExportTask.java b/app/src/main/java/com/battlelancer/seriesguide/dataliberation/JsonExportTask.java index 786ea045fc..f53d8ba49d 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/dataliberation/JsonExportTask.java +++ b/app/src/main/java/com/battlelancer/seriesguide/dataliberation/JsonExportTask.java @@ -258,6 +258,12 @@ private int exportData(File exportPath, @BackupType int type) { } FileOutputStream out = new FileOutputStream(pfd.getFileDescriptor()); + // Even though using streams and FileOutputStream does not append by + // default, using Storage Access Framework just overwrites existing + // bytes, potentially leaving old bytes hanging over: + // so truncate the file first to clear any existing bytes. + out.getChannel().truncate(0); + if (type == BACKUP_SHOWS) { writeJsonStreamShows(out, data); } else if (type == BACKUP_LISTS) {