Why to use strings.xml?

后端 未结 3 912
滥情空心
滥情空心 2020-12-03 13:05

Could anyone please explain why having hard-coded strings is so bad? What issues should I expect if I hardcode strings? Why having a separate string xml file solves those is

3条回答
  •  暖寄归人
    2020-12-03 13:55

    Plus, suppose you have a string, let it be a title for example, that is repeated in every activity of your app. Now suppose after awhile, you decide to change that title.

    Using strings.xml you will need to change it in a single place, while hard-coded values will need to be changed in every activity.

提交回复
热议问题