public static void setWhitelist(SharedPreferences prefs, String languageCode, String whitelist) {
    if (languageCode.equals("afr")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_AFRIKAANS, whitelist).commit(); }
    else if (languageCode.equals("sqi")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_ALBANIAN, whitelist).commit(); }
    else if (languageCode.equals("ara")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_ARABIC, whitelist).commit(); }
    else if (languageCode.equals("aze")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_AZERI, whitelist).commit(); }
    else if (languageCode.equals("eus")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_BASQUE, whitelist).commit(); }
    else if (languageCode.equals("bel")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_BELARUSIAN, whitelist).commit(); }
    else if (languageCode.equals("ben")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_BENGALI, whitelist).commit(); }
    else if (languageCode.equals("bul")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_BULGARIAN, whitelist).commit(); }
    else if (languageCode.equals("cat")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_CATALAN, whitelist).commit(); }
    else if (languageCode.equals("chi_sim")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_CHINESE_SIMPLIFIED, whitelist).commit(); }
    else if (languageCode.equals("chi_tra")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_CHINESE_TRADITIONAL, whitelist).commit(); }
    else if (languageCode.equals("hrv")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_CROATIAN, whitelist).commit(); }
    else if (languageCode.equals("ces")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_CZECH, whitelist).commit(); }
    else if (languageCode.equals("dan")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_DANISH, whitelist).commit(); }
    else if (languageCode.equals("nld")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_DUTCH, whitelist).commit(); }
    else if (languageCode.equals("eng")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_ENGLISH, whitelist).commit(); }
    else if (languageCode.equals("est")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_ESTONIAN, whitelist).commit(); }
    else if (languageCode.equals("fin")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_FINNISH, whitelist).commit(); }
    else if (languageCode.equals("fra")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_FRENCH, whitelist).commit(); }
    else if (languageCode.equals("glg")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_GALICIAN, whitelist).commit(); }
    else if (languageCode.equals("deu")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_GERMAN, whitelist).commit(); }
    else if (languageCode.equals("ell")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_GREEK, whitelist).commit(); }
    else if (languageCode.equals("heb")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_HEBREW, whitelist).commit(); }
    else if (languageCode.equals("hin")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_HINDI, whitelist).commit(); }
    else if (languageCode.equals("hun")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_HUNGARIAN, whitelist).commit(); }
    else if (languageCode.equals("isl")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_ICELANDIC, whitelist).commit(); }
    else if (languageCode.equals("ind")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_INDONESIAN, whitelist).commit(); }
    else if (languageCode.equals("ita")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_ITALIAN, whitelist).commit(); }
    else if (languageCode.equals("jpn")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_JAPANESE, whitelist).commit(); }
    else if (languageCode.equals("kan")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_KANNADA, whitelist).commit(); }
    else if (languageCode.equals("kor")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_KOREAN, whitelist).commit(); }
    else if (languageCode.equals("lav")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_LATVIAN, whitelist).commit(); }
    else if (languageCode.equals("lit")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_LITHUANIAN, whitelist).commit(); }
    else if (languageCode.equals("mkd")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_MACEDONIAN, whitelist).commit(); }
    else if (languageCode.equals("msa")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_MALAY, whitelist).commit(); }
    else if (languageCode.equals("mal")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_MALAYALAM, whitelist).commit(); }
    else if (languageCode.equals("mlt")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_MALTESE, whitelist).commit(); }
    else if (languageCode.equals("nor")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_NORWEGIAN, whitelist).commit(); }
    else if (languageCode.equals("pol")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_POLISH, whitelist).commit(); }
    else if (languageCode.equals("por")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_PORTUGUESE, whitelist).commit(); }
    else if (languageCode.equals("ron")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_ROMANIAN, whitelist).commit(); }
    else if (languageCode.equals("rus")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_RUSSIAN, whitelist).commit(); }
    else if (languageCode.equals("srp")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_SERBIAN, whitelist).commit(); }
    else if (languageCode.equals("slk")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_SLOVAK, whitelist).commit(); }
    else if (languageCode.equals("slv")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_SLOVENIAN, whitelist).commit(); }
    else if (languageCode.equals("spa")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_SPANISH, whitelist).commit(); }
    else if (languageCode.equals("swa")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_SWAHILI, whitelist).commit(); }
    else if (languageCode.equals("swe")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_SWEDISH, whitelist).commit(); }
    else if (languageCode.equals("tgl")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_TAGALOG, whitelist).commit(); }
    else if (languageCode.equals("tam")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_TAMIL, whitelist).commit(); }
    else if (languageCode.equals("tel")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_TELUGU, whitelist).commit(); }
    else if (languageCode.equals("tha")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_THAI, whitelist).commit(); }
    else if (languageCode.equals("tur")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_TURKISH, whitelist).commit(); }
    else if (languageCode.equals("ukr")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_UKRAINIAN, whitelist).commit(); }
    else if (languageCode.equals("vie")) { prefs.edit().putString(KEY_CHARACTER_WHITELIST_VIETNAMESE, whitelist).commit(); }
    else {
      throw new IllegalArgumentException();
    }    
  }
Helper class to enable language-specific character blacklists/whitelists.
OCRTest/src/main/java/edu/sfsu/cs/orange/ocr/OcrCharacterHelper.java