change global contant value

0

Good afternoon,

I would like to know if it is possible to change the value received by a global constant and set another value. For example, I get the value of the color that is set in the settings of the edge lighting of Samsung devices, and I want my app to send a new color to it.

public class EdgeLightingSettings {

    public static final class Global {
        public static final String EDGELIGHTING_CUSTOM_COLOR = "edgelighting_custom_color";


    }
}

Here I get the value that is customized by the user in the native configuration of the edge screen. I want to change this in the code.

Is there a way? O.o

    
asked by anonymous 26.06.2018 / 22:32

1 answer

0

By language definition, any constant (which in java is represented by the final modifier) can not be changed.

If you want a global value but can be changed, you must remove the final modifier and keep only the static modifier. In your case, it would look like:

public class EdgeLightingSettings {

    public static class Global {
        public static String EDGELIGHTING_CUSTOM_COLOR = "edgelighting_custom_color";
    }
}

In this way, you could change the value of EDGELIGHTING_CUSTOM_COLOR by calling:

Global.EDGELIGHTING_CUSTOM_COLOR = "Seu valor";
    
27.06.2018 / 23:14