I'm a newbie to Android Studio and I just wanna know why instead of hardcoding strings in the layout, it's a best practice to use string resources. Could you please try to explain this to me in less technical human friendly language.
3 Answers
when you want to change the content of the string it is easier to look for the same in the strings.xml and change it there, and it reflects everywhere you have used it.
if you are using the same string constant across multiple files, you can just change it in one place rather than changing it in multiple files,
it also prevents typo and mistakes and also increases the readability of the code

- 675
- 2
- 11
- 28
If you hardcode strings, you can't support multi languages. The second reason is reusability, if it's hardcoded, for example word "next" on the button, and you want to change to "continue", you have to update all xml buttons. With resources you have to update one string.

- 689
- 6
- 20
You can hardcode but if your application needs to support multiple language resources comes in handy.
1> Language support -> Useful if you need to support multiple languages in the application. You can load resources according to locale/language of the application.
2> Resuablility -> if you have some error message, which is used in multiple places, using resources comes in handy. In future you want to change the error message, you have to make changes only once.

- 1,452
- 15
- 25