diff --git a/library/core/src/main/java/com/google/android/exoplayer2/offline/ActionFile.java b/library/core/src/main/java/com/google/android/exoplayer2/offline/ActionFile.java index f77c83b33b..a62fb02ff5 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/offline/ActionFile.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/offline/ActionFile.java @@ -31,13 +31,11 @@ public final class ActionFile { /* package */ static final int VERSION = 0; private final AtomicFile atomicFile; - private final File actionFile; /** * @param actionFile File to be used to store and load {@link DownloadAction}s. */ public ActionFile(File actionFile) { - this.actionFile = actionFile; atomicFile = new AtomicFile(actionFile); } @@ -48,7 +46,7 @@ public final class ActionFile { * @throws IOException If there is an error during loading. */ public DownloadAction[] load() throws IOException { - if (!actionFile.exists()) { + if (!exists()) { return new DownloadAction[0]; } InputStream inputStream = null; @@ -93,4 +91,13 @@ public final class ActionFile { } } + /** Returns whether the file or its backup exists. */ + public boolean exists() { + return atomicFile.exists(); + } + + /** Delete the action file and its backup. */ + public void delete() { + atomicFile.delete(); + } } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java b/library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java index 6fdb00dff2..74e50dfd92 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java @@ -52,7 +52,7 @@ public final class AtomicFile { backupName = new File(baseName.getPath() + ".bak"); } - /** Whether the file or its backup exists. */ + /** Returns whether the file or its backup exists. */ public boolean exists() { return baseName.exists() || backupName.exists(); }