diff --git a/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.java b/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.java index 228860fdd..5c54449d0 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.java @@ -80,6 +80,8 @@ public class RingtoneSelectionController extends BaseController implements Flexi private MediaPlayer mediaPlayer; private Handler cancelMediaPlayerHandler; + private Cursor cursor; + public RingtoneSelectionController(Bundle args) { super(args); setHasOptionsMenu(true); @@ -180,7 +182,7 @@ public class RingtoneSelectionController extends BaseController implements Flexi manager.setType(RingtoneManager.TYPE_NOTIFICATION); } - Cursor cursor = manager.getCursor(); + cursor = manager.getCursor(); NotificationSoundItem notificationSoundItem; @@ -212,8 +214,6 @@ public class RingtoneSelectionController extends BaseController implements Flexi } } } - - cursor.close(); } adapter.updateDataSet(abstractFlexibleItemList, true); @@ -299,6 +299,9 @@ public class RingtoneSelectionController extends BaseController implements Flexi @Override public void onDestroy() { endMediaPlayer(); + if (cursor != null) { + cursor.close(); + } super.onDestroy(); }