From 348dc08f7359b06a2eff8e4431aa144a40197a97 Mon Sep 17 00:00:00 2001 From: Prathamesh More Date: Fri, 19 Nov 2021 17:44:07 +0530 Subject: [PATCH] Changed backup root path to Documents --- .../monkey/retromusic/helper/BackupHelper.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/BackupHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/BackupHelper.kt index 018cb507..02eff857 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/BackupHelper.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/BackupHelper.kt @@ -14,16 +14,16 @@ import java.util.zip.ZipOutputStream object BackupHelper { suspend fun createBackup(context: Context, name: String) { + val backupFile = + File(backupRootPath + name + APPEND_EXTENSION) + if (backupFile.parentFile?.exists() != true) { + backupFile.parentFile?.mkdirs() + } + val zipItems = mutableListOf() + zipItems.addAll(getDatabaseZipItems(context)) + zipItems.addAll(getSettingsZipItems(context)) + getUserImageZipItems(context)?.let { zipItems.addAll(it) } withContext(Dispatchers.IO) { - val backupFile = - File(backupRootPath + name + APPEND_EXTENSION) - if (backupFile.parentFile?.exists() != true) { - backupFile.parentFile?.mkdirs() - } - val zipItems = mutableListOf() - zipItems.addAll(getDatabaseZipItems(context)) - zipItems.addAll(getSettingsZipItems(context)) - getUserImageZipItems(context)?.let { zipItems.addAll(it) } zipAll(zipItems, backupFile) } } @@ -130,7 +130,8 @@ object BackupHelper { } val backupRootPath = - Environment.getExternalStorageDirectory().toString() + "/RetroMusic/Backups/" + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + .toString() + "/RetroMusic/Backups/" const val BACKUP_EXTENSION = "rmbak" const val APPEND_EXTENSION = ".$BACKUP_EXTENSION" private const val DATABASES_PATH = "databases"