0

I work on Android project with AndroidAnnotations and I want to use it for SharedPreferences. I want to use @DefaultStringSet. When I want to define default value with a String[] I got error:

Attribute value must be constant

The same happens for HashSet. I also tried to define public static variable of type String[], but nothing changes. According to this there is no way to set constant for anything but primitives and Strings.

I looked for examples, but found nothing. So what is the way to initialize this preference, is this doable?

I work on AndroidAnnotations 4.1.0

Community
  • 1
  • 1
Wojciech
  • 13
  • 6

1 Answers1

0

An array initializer is also a constant expression, that is how it can be used in annotations:

@DefaultStringSet({"one", "two", "three"})
WonderCsabo
  • 11,947
  • 13
  • 63
  • 105