I write dynamic preferences and I have an IllegalStateException with this code :
String key = "pref_key1";
CheckBoxPreference pref1 = new CheckBoxPreference(getActivity());
pref1.setKey(key);
Preference pref2 = new Preference(getActivity());
pref2.setKey("pref_key2");
pref2.setDependency(key);
The error is :
java.lang.IllegalStateException: Dependency "pref_key1" not found for preference "pref_key2"
Can you help me ? Thanks in advance