2525import org .schabi .newpipe .extractor .NewPipe ;
2626import org .schabi .newpipe .extractor .localization .ContentCountry ;
2727import org .schabi .newpipe .extractor .localization .Localization ;
28- import org .schabi .newpipe .util .FilePickerActivityHelper ;
2928import org .schabi .newpipe .util .FilePathUtils ;
29+ import org .schabi .newpipe .util .FilePickerActivityHelper ;
3030import org .schabi .newpipe .util .ZipHelper ;
3131
3232import java .io .File ;
@@ -178,11 +178,9 @@ public void onActivityResult(final int requestCode, final int resultCode,
178178 && resultCode == Activity .RESULT_OK && data .getData () != null ) {
179179 final File file = Utils .getFileForUri (data .getData ());
180180 final String path = file .getAbsolutePath ();
181- setImportExportDataPath (file );
182181
183182 if (requestCode == REQUEST_EXPORT_PATH ) {
184- final SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMMdd_HHmmss" , Locale .US );
185- exportDatabase (path + "/NewPipeData-" + sdf .format (new Date ()) + ".zip" );
183+ exportDatabase (file );
186184 } else {
187185 final AlertDialog .Builder builder = new AlertDialog .Builder (requireActivity ());
188186 builder .setMessage (R .string .override_current_data )
@@ -195,15 +193,21 @@ public void onActivityResult(final int requestCode, final int resultCode,
195193 }
196194 }
197195
198- private void exportDatabase (final String path ) {
196+ private void exportDatabase (final File folder ) {
199197 try {
198+ final SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMMdd_HHmmss" , Locale .US );
199+ final String path = folder .getAbsolutePath () + "/NewPipeData-"
200+ + sdf .format (new Date ()) + ".zip" ;
201+
200202 //checkpoint before export
201203 NewPipeDatabase .checkpoint ();
202204
203205 final SharedPreferences preferences = PreferenceManager
204- .getDefaultSharedPreferences (requireContext ());
206+ .getDefaultSharedPreferences (requireContext ());
205207 manager .exportDatabase (preferences , path );
206208
209+ setImportExportDataPath (folder );
210+
207211 Toast .makeText (getContext (), R .string .export_complete_toast , Toast .LENGTH_SHORT ).show ();
208212 } catch (final Exception e ) {
209213 ErrorActivity .reportUiErrorInSnackbar (this , "Exporting database" , e );
0 commit comments