Changed backup root path to Documents

This commit is contained in:
Prathamesh More 2021-11-19 17:44:07 +05:30
parent 484d003a3b
commit 348dc08f73

View file

@ -14,7 +14,6 @@ import java.util.zip.ZipOutputStream
object BackupHelper {
suspend fun createBackup(context: Context, name: String) {
withContext(Dispatchers.IO) {
val backupFile =
File(backupRootPath + name + APPEND_EXTENSION)
if (backupFile.parentFile?.exists() != true) {
@ -24,6 +23,7 @@ object BackupHelper {
zipItems.addAll(getDatabaseZipItems(context))
zipItems.addAll(getSettingsZipItems(context))
getUserImageZipItems(context)?.let { zipItems.addAll(it) }
withContext(Dispatchers.IO) {
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"