Improve documentation
This commit is contained in:
parent
2756ef6d2f
commit
f0db2aa43c
2 changed files with 12 additions and 4 deletions
|
@ -187,6 +187,7 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment {
|
||||||
throw new IOException("Could not create databases dir");
|
throw new IOException("Could not create databases dir");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replace the current database
|
||||||
if (!manager.extractDb(file)) {
|
if (!manager.extractDb(file)) {
|
||||||
Toast.makeText(requireContext(), R.string.could_not_import_all_files,
|
Toast.makeText(requireContext(), R.string.could_not_import_all_files,
|
||||||
Toast.LENGTH_LONG)
|
Toast.LENGTH_LONG)
|
||||||
|
@ -265,7 +266,7 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save import path and restart system.
|
* Save import path and restart app.
|
||||||
*
|
*
|
||||||
* @param importDataUri The import path to save
|
* @param importDataUri The import path to save
|
||||||
*/
|
*/
|
||||||
|
@ -290,6 +291,7 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment {
|
||||||
private void showErrorSnackbar(final Throwable e, final String request) {
|
private void showErrorSnackbar(final Throwable e, final String request) {
|
||||||
ErrorUtil.showSnackbar(this, new ErrorInfo(e, UserAction.DATABASE_IMPORT_EXPORT, request));
|
ErrorUtil.showSnackbar(this, new ErrorInfo(e, UserAction.DATABASE_IMPORT_EXPORT, request));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createErrorNotification(final Throwable e, final String request) {
|
private void createErrorNotification(final Throwable e, final String request) {
|
||||||
ErrorUtil.createNotification(
|
ErrorUtil.createNotification(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
|
|
|
@ -67,11 +67,17 @@ class ImportExportManager(private val fileLocator: BackupFileLocator) {
|
||||||
return fileLocator.dbDir.exists() || fileLocator.dbDir.mkdir()
|
return fileLocator.dbDir.exists() || fileLocator.dbDir.mkdir()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the database from the given file to the app's database directory.
|
||||||
|
* The current app's database will be overwritten.
|
||||||
|
* @param file the .zip file to extract the database from
|
||||||
|
* @return true if the database was successfully extracted, false otherwise
|
||||||
|
*/
|
||||||
fun extractDb(file: StoredFileHelper): Boolean {
|
fun extractDb(file: StoredFileHelper): Boolean {
|
||||||
val success = ZipHelper.extractFileFromZip(
|
val success = ZipHelper.extractFileFromZip(
|
||||||
file,
|
file,
|
||||||
BackupFileLocator.FILE_NAME_DB,
|
BackupFileLocator.FILE_NAME_DB,
|
||||||
fileLocator.db.path,
|
fileLocator.db.path,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|
Loading…
Reference in a new issue