Android – where do you store string values? In the strings.xml or constants class?
•
Android
In Android, we can store string values in the strings.xml file or in some constant classes as static final variables. In some cases, is there any reason to choose one on the other?
resolvent:
In short:
Values used in the code: always constants class. Advantage: the code remains integrated and your package can be used in other projects / contexts. You can't do this with string.xml because it doesn't ship with your package
Value displayed in UI: use string. XML. Advantage: you can use localization to display translated text
When both options are feasible, something may happen. Then, you must determine the storage location of its related values
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码