Is it possible to use Enum in Android like this?
public enum EventAction
{
SDCARD_MOUNTED
{
public String toString() {
return "External SDCard was mounted";
}
public int getCode() {
return 25;
}
}
}
From the outside code I have an access only to EventAction.SDCARD_MOUNTED.toString() but .getCode() is not visible. Examples I saw show how getCode() is used from inside code.
Declare
getCode()as anabstractmethod:If every value is going to be implemented the same way, it’s clearer to do this: