mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 23:07:26 -04:00
Surround file deletion with a try catch block
This commit is contained in:
parent
95a606ed8d
commit
ef25f8ea16
@ -2,11 +2,11 @@ package org.kiwix.kiwixmobile;
|
||||
|
||||
import org.kiwix.kiwixmobile.settings.Constants;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
public static File getFileCacheDir(Context context) {
|
||||
@ -21,11 +21,14 @@ public class FileUtils {
|
||||
}
|
||||
|
||||
|
||||
public static void deleteCachedFiles(Context context) {
|
||||
for (File file : getFileCacheDir(context).listFiles()) {
|
||||
file.delete();
|
||||
public static synchronized void deleteCachedFiles(Context context) {
|
||||
try {
|
||||
for (File file : getFileCacheDir(context).listFiles()) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +64,7 @@ public class FileUtils {
|
||||
* @return true if it does exist, false otherwise
|
||||
*/
|
||||
static public boolean doesFileExist(String fileName, long fileSize,
|
||||
boolean deleteFileOnMismatch) {
|
||||
boolean deleteFileOnMismatch) {
|
||||
// the file may have been delivered by Market --- let's make sure
|
||||
// it's the size we expect
|
||||
File fileForNewFile = new File(fileName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user