0

我在我的活动中遇到了这个错误

05-30 12:19:23.562: E/AndroidRuntime(408): java.lang.NoSuchMethodError: android.content.SharedPreferences.getStringSet

我已经尝试过关于 SO 的不同建议来解决这个问题,但我仍然找不到我出错的地方。这是我的代码:(在我的简历上)

....
    arraylistUri = new ArrayList<Uri>();
    arraylistConsumer = new ArrayList<String>();
    arraylistConsumerId = new ArrayList<String>();

    arraylistSelectedConsumerIds = new ArrayList<String>();
    arraylistSelectedConsumer = new ArrayList<String>();
    arrayListExportedConsumerId = new ArrayList<String>();
    arrayListExportedConsumer = new ArrayList<String>();

    sharedPreferences = getSharedPreferences(Constants.SHARED_PREFERENCES_CREATOR, 0);
    sharedPreferencesEditor = sharedPreferences.edit();

    exportedConsumerId = new HashSet<String>();
    exportedConsumer = new HashSet<String>();
    exportedConsumerId = sharedPreferences.getStringSet(Constants.SHARED_PREFERENCES_EXPORTED_CONSUMER_ID, null);
    exportedConsumer = sharedPreferences.getStringSet(Constants.SHARED_PREFERENCES_EXPORTED_CONSUMER, null);

....

这是我的按钮 onclicklistener 上的代码,我在 sharedpreference 上使用 put 字符串

....
arraylistUri = new ArrayList<Uri>();
    arraylistConsumer = new ArrayList<String>();
    arraylistConsumerId = new ArrayList<String>();

    arraylistSelectedConsumerIds = new ArrayList<String>();
    arraylistSelectedConsumer = new ArrayList<String>();
    arrayListExportedConsumerId = new ArrayList<String>();
    arrayListExportedConsumer = new ArrayList<String>();

    sharedPreferences = getSharedPreferences(Constants.SHARED_PREFERENCES_CREATOR, 0);
    sharedPreferencesEditor = sharedPreferences.edit();

    exportedConsumerId = new HashSet<String>();
    exportedConsumer = new HashSet<String>();
    exportedConsumerId = sharedPreferences.getStringSet(Constants.SHARED_PREFERENCES_EXPORTED_CONSUMER_ID, null);
    exportedConsumer = sharedPreferences.getStringSet(Constants.SHARED_PREFERENCES_EXPORTED_CONSUMER, null);
....
4

1 回答 1

0

getStringSet 方法仅支持 API 级别 11 http://developer.android.com/reference/android/content/SharedPreferences.html#getStringSet%28java.lang.String,%20java.util.Set%3Cjava.lang.String% 3E%29

于 2013-12-16T01:42:01.333 回答