Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining Strings in res/values/string.xml?

Tags:

android

What's the point of defining strings in xml at the res/values/string.xml directory? Is it more efficient than just defining the strings as constants within your classes? (e.g. Database table creation scripts, etc..)

Is it a matter of organization or is there some benefit in how Android handles these objects in memory?

like image 942
tpow Avatar asked Dec 16 '22 19:12

tpow


2 Answers

  • So you can easily translate them into different languages.
  • So they're nicely organized and you have them all in one place.
like image 126
EboMike Avatar answered Dec 19 '22 07:12

EboMike


You can easily translate your app if you use strings.xml. Just create a new folder with suffix like values-cs and put the xml with czech strings in it and the whole app will be translated to czech if you have set czech localization in your phone.

like image 37
martinpelant Avatar answered Dec 19 '22 07:12

martinpelant