Annotation Type Preferences
-
@Target(TYPE) @Retention(CLASS) public @interface PreferencesDefines a set of preferences. A preference class for easier and type-safe access toSharedPreferencesis generated from this annotation.
Example
Source Code{@code @Preferences(name = "org.example.AppPreferences$Generated", r = R.class, value = {
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.StringnameThe fully qualified class name of the generated preferences class.java.lang.Class<?>rThe type of the app'sRclass.PreferenceGroup[]valueA list ofPreferenceGroups.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleaneditorWhether to generate anEditorclass similar toSharedPreferences.Editor.booleanfluentWhether the generated code should use fluent accessors or stick to the traditional getter/setter prefixes.booleanmakeFileWhether the generated class should bepublic finalwith aprivateconstructor, or package-private non-finalwith aprotectedconstructor.
-
-
-
-
value
PreferenceGroup[] value
A list ofPreferenceGroups.
-
-
-
makeFile
boolean makeFile
Whether the generated class should bepublic finalwith aprivateconstructor, or package-private non-finalwith aprotectedconstructor.
Having the generated class be non-finalallows the syntax
Either way the generated class will throw an exception on instantiation.@Preferences(name = "Prefs$Generated", ...)public class Prefs extends Prefs$Generated {}- Default:
- false
-
-