Enums on Android

From this topic, we know Google suggests not to use Enum because of “Enums often require more than twice as much memory as static constants. You should strictly avoid using enums on Android.”

I know enum definition extends java.lang.Enum class, so adding an enum class would make application has an extra class, which would increase more DEX size and memory allocation than static constants.

But, it’s not a good reason to avoid Enums, because generally a developer would only add an enum when it’s useful. I would assume we never use enum as integer and just call ordinal() only.

I will still use enum if needed, and more, I like to use annotations instead of emum, it’s good to check on compiler warning and has better memory usage. Th enumed annotation can decorate a return value or a method parameter, and give warning about whether types which are accepted or not.