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:
parent
9702189be4
commit
93f03bab87
1 changed files with 4 additions and 2 deletions
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue