Make sure to close the outputstream of the export

This commit is contained in:
cpfeiffer
2018-02-24 21:02:53 +01:00
parent bf729f41b2
commit 6370c6cac1
@@ -65,8 +65,9 @@ public class PeriodicExporter extends BroadcastReceiver {
return;
}
Uri dstUri = Uri.parse(dst);
OutputStream out = context.getContentResolver().openOutputStream(dstUri);
helper.exportDB(dbHandler, out);
try (OutputStream out = context.getContentResolver().openOutputStream(dstUri)) {
helper.exportDB(dbHandler, out);
}
} catch (Exception ex) {
GB.updateExportFailedNotification(context.getString(R.string.notif_export_failed_title), context);
LOG.info("Exception while exporting DB: ", ex);