1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-11-17 15:47:12 +00:00

Call checkpoint creation from an executor

java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2025-11-17 16:09:45 +08:00
parent c399fd9e3e
commit 0fb5097270

View File

@@ -40,6 +40,8 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class BackupRestoreSettingsFragment extends BasePreferenceFragment {
@@ -155,9 +157,9 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment {
}
private void exportDatabase(final StoredFileHelper file, final Uri exportDataUri) {
try {
try (ExecutorService executor = Executors.newSingleThreadExecutor()) {
//checkpoint before export
NewPipeDatabase.checkpoint();
executor.submit(NewPipeDatabase::checkpoint).get();
final SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(requireContext());