String.xml or Constants class

回眸只為那壹抹淺笑 提交于 2019-12-31 09:15:29

问题


What is better approach of the following in designing an Android app

  1. To place all the String constants in res/values/Strings.xml or
  2. Create a class like Constant.java where all Strings are public static final?

Choosing which one of them is more efficient?


回答1:


I imagine a constants class would be more efficient.

However, speed shouldn't really be an issue in either case. I would recommend organizing based on what makes sense.

Constants class

Put strings constants that will be used internally, like database column names or other keys.

strings.xml

Put strings that are displayed for the user. This way you can take advantage of localization, etc.



来源:https://stackoverflow.com/questions/8380751/string-xml-or-constants-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!