<commit_before>package cn.ycoder.android.library.tool.objectify;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;

/**
 * Created by tsung on 3/31/14.
 */
public class StringPreferenceLoader extends PreferenceLoader {
    public StringPreferenceLoader(Context context, String key) {
        super(context, key);
    }

    public String load() throws NoSuchPreferenceFoundException {
        SharedPreferences appSharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
        String value = appSharedPrefs.getString(getKey(), "");
        if (TextUtils.isEmpty(value)) {
            throw new NoSuchPreferenceFoundException();
        }
        return value;
    }

    public void save(String value) {
        SharedPreferences appSharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
        SharedPreferences.Editor prefsEditor = appSharedPrefs.edit();
        prefsEditor.putString(getKey(), value);
        prefsEditor.apply();
    }
}<commit_msg>修正：String值可为空<commit_after>package cn.ycoder.android.library.tool.objectify;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * Created by tsung on 3/31/14.
 */
public class StringPreferenceLoader extends PreferenceLoader {

  public StringPreferenceLoader(Context context, String key) {
    super(context, key);
  }

  public String load() throws NoSuchPreferenceFoundException {
    SharedPreferences appSharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    String value = appSharedPrefs.getString(getKey(), "");
    return value;
  }

  public void save(String value) {
    SharedPreferences appSharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor prefsEditor = appSharedPrefs.edit();
    prefsEditor.putString(getKey(), value);
    prefsEditor.apply();
  }
}
{'fraction_non_alphanumeric': 0.0914572864321608, 'fraction_numerical': 0.005025125628140704, 'mean_word_length': 4.46978021978022, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '263931', 'n_tokens_mistral': 534, 'n_tokens_neox': 526, 'n_words': 109}