private void updateUserDictionaryPreference(Preference userDictionaryPreference) {
final Activity activity = getActivity();
final Set<String> localeList = UserDictionaryList.getUserDictionaryLocalesList(activity);
- if (localeList.size() <= 1) {
+ if (null == localeList) {
+ // The locale list is null if and only if the user dictionary service is
+ // not present or disabled. In this case we need to remove the preference.
+ ((PreferenceGroup)findPreference("language_settings_category")).removePreference(
+ userDictionaryPreference);
+ } else if (localeList.size() <= 1) {
userDictionaryPreference.setTitle(R.string.user_dict_single_settings_title);
userDictionaryPreference.setFragment(UserDictionarySettings.class.getName());
// If the size of localeList is 0, we don't set the locale parameter in the
new String[] { UserDictionary.Words.LOCALE },
null, null, null);
final Set<String> localeList = new TreeSet<String>();
- if (null != cursor && cursor.moveToFirst()) {
+ if (null == cursor) {
+ // The user dictionary service is not present or disabled. Return null.
+ return null;
+ } else if (cursor.moveToFirst()) {
final int columnIndex = cursor.getColumnIndex(UserDictionary.Words.LOCALE);
do {
String locale = cursor.getString(columnIndex);