use apply() to store preferences.

This commit is contained in:
Adrian Ulrich 2018-10-14 19:54:52 +02:00
parent ce9ccd9bd4
commit d1af6dab36
2 changed files with 7 additions and 16 deletions

View File

@ -26,15 +26,11 @@ import java.util.ArrayList;
public class FilebrowserStartActivity extends FolderPickerActivity {
private SharedPreferences.Editor mPrefEditor;
@Override
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.filebrowser_start);
mPrefEditor = PlaybackService.getSettings(this).edit();
// Make sure that we display the current selection
File startPath = FileUtils.getFilesystemBrowseStart(this);
setCurrentDir(startPath);
@ -43,8 +39,9 @@ public class FilebrowserStartActivity extends FolderPickerActivity {
@Override
public void onFolderPicked(File directory, ArrayList<String> a, ArrayList<String> b) {
mPrefEditor.putString(PrefKeys.FILESYSTEM_BROWSE_START, directory.getAbsolutePath());
mPrefEditor.commit();
SharedPreferences.Editor editor = PlaybackService.getSettings(this).edit();
editor.putString(PrefKeys.FILESYSTEM_BROWSE_START, directory.getAbsolutePath());
editor.apply();
finish();
}

View File

@ -25,29 +25,23 @@ import java.io.File;
import java.util.ArrayList;
public class PlaylistObserverDirActivity extends FolderPickerActivity {
/**
* Shared preferences
*/
private SharedPreferences mPrefs;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.filebrowser_start);
mPrefs = PlaybackService.getSettings(this);
// Start at currently configured directory.
String current = mPrefs.getString(PrefKeys.PLAYLIST_SYNC_FOLDER, PrefDefaults.PLAYLIST_SYNC_FOLDER);
String current = PlaybackService.getSettings(this).getString(PrefKeys.PLAYLIST_SYNC_FOLDER, PrefDefaults.PLAYLIST_SYNC_FOLDER);
setCurrentDir(new File(current));
}
@Override
public void onFolderPicked(File directory, ArrayList<String> a, ArrayList<String> b) {
SharedPreferences.Editor editor = mPrefs.edit();
SharedPreferences.Editor editor = PlaybackService.getSettings(this).edit();
editor.putString(PrefKeys.PLAYLIST_SYNC_FOLDER, directory.getAbsolutePath());
editor.commit();
editor.apply();
finish();
}